forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@605 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
b0c6574dd3
commit
ed03a2c2df
@ -0,0 +1,88 @@
|
||||
package siprp.logic;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import siprp.ui.SIPRPWindow;
|
||||
|
||||
public class SIPRPLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* Declares an Action
|
||||
*
|
||||
* @author tsimao
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Action
|
||||
{
|
||||
/**
|
||||
* true - this action saves data to de database from the components
|
||||
* false - this action reads from the database to the components
|
||||
*/
|
||||
boolean isSave();
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a UI method with an action
|
||||
*
|
||||
* @author tsimao
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LeafUIActionBinding
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the action this method binds to
|
||||
*/
|
||||
String action();
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a logic methods with a group of actions
|
||||
*
|
||||
* @author tsimao
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LeafLogicActionBinding
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the action this method binds to
|
||||
*/
|
||||
String [] actions();
|
||||
}
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String ACTION_STARTUP = "ACTION_STARTUP";
|
||||
|
||||
|
||||
private List<SIPRPWindow> registeredWindows = new ArrayList<SIPRPWindow>();
|
||||
|
||||
public void addWindow(SIPRPWindow window)
|
||||
{
|
||||
registeredWindows .add(window);
|
||||
}
|
||||
|
||||
public void runAction( String actionName )
|
||||
{
|
||||
for( SIPRPWindow window : registeredWindows )
|
||||
{
|
||||
window.runAction( actionName );
|
||||
}
|
||||
}
|
||||
|
||||
public void runAction( String actionName, Object argument )
|
||||
{
|
||||
for( SIPRPWindow window : registeredWindows )
|
||||
{
|
||||
window.runAction( actionName, argument );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package siprp.medicina.processo.database;
|
||||
|
||||
public class MedicinaProcessoDAO
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,314 @@
|
||||
package siprp.medicina.processo.logic;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import siprp.database.cayenne.objects.BaseObject;
|
||||
import siprp.database.cayenne.objects.Trabalhadores;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcds;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
|
||||
import siprp.database.cayenne.providers.MedicinaDAO;
|
||||
import siprp.logic.SIPRPLogic;
|
||||
import siprp.medicina.MedicinaConstants;
|
||||
import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode;
|
||||
import siprp.ui.SIPRPWindow.LeafObject;
|
||||
|
||||
import com.evolute.utils.tables.ColumnizedMappable;
|
||||
|
||||
public class MedicinaProcessoLogic extends SIPRPLogic
|
||||
{
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EMPRESA = "SELECT_EMPRESA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_ESTABELECIMENTO = "SELECT_ESTABLECIMENTO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_TRABALHADOR = "SELECT_TRABALHADOR";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_PROCESSO = "SELECT_PROCESSO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA = "SELECT_CONSULTA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA_MARCACAO = "SELECT_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA_MARCACAO_EMAIL = "SELECT_CONSULTA_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA_MARCACAO_OBSERVACAO = "SELECT_CONSULTA_MARCACAO_OBSERVACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME = "SELECT_EXAME";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME_MARCACAO = "SELECT_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME_MARCACAO_EMAIL = "SELECT_EXAME_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME_MARCACAO_OBSERVACAO = "SELECT_EXAME_MARCACAO_OBSERVACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_FICHA = "SELECT_FICHA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_TREE_NODE = "SELECT_TREE_NODE";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA = "CREATE_CONSULTA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA_MARCACAO = "CREATE_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA_MARCACAO_EMAIL = "CREATE_CONSULTA_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA_MARCACAO_OBSERVACOES = "CREATE_CONSULTA_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME = "CREATE_EXAME";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME_MARCACAO = "CREATE_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME_MARCACAO_EMAIL = "CREATE_EXAME_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME_MARCACAO_OBSERVACOES = "CREATE_EXAME_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA = "SAVE_CONSULTA";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA_MARCACAO = "SAVE_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA_MARCACAO_EMAIL = "SAVE_CONSULTA_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA_MARCACAO_OBSERVACOES = "SAVE_CONSULTA_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME = "SAVE_EXAME";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME_MARCACAO = "SAVE_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME_MARCACAO_EMAIL = "SAVE_EXAME_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME_MARCACAO_OBSERVACOES = "SAVE_EXAME_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE = "SAVE";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String REVERT = "REVERT";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String REFRESH = "REFRESH";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CLOSE = "CLOSE";
|
||||
|
||||
private MedicinaDAO provider = null;
|
||||
|
||||
private Trabalhadores currentTrabalhador = null;
|
||||
|
||||
private TrabalhadoresProcesso currentProcesso = null;
|
||||
|
||||
@LeafObject(useWithAction=SAVE_CONSULTA)
|
||||
public TrabalhadoresConsultas currentConsulta = null;
|
||||
|
||||
@LeafObject(useWithAction=SAVE_CONSULTA_MARCACAO)
|
||||
public TrabalhadoresConsultasDatas currentConsultaMarcacao = null;
|
||||
|
||||
@LeafObject(useWithAction=SAVE_CONSULTA_MARCACAO_EMAIL)
|
||||
public TrabalhadoresConsultasDatasEmails currentConsultaMarcacaoEmail = null;
|
||||
|
||||
@LeafObject(useWithAction=SAVE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public TrabalhadoresConsultasDatasObservacoes currentConsultaMarcacaoObservacao = null;
|
||||
|
||||
public FichaAptidaoMutableTreeNode currentFicha = null;
|
||||
|
||||
public TrabalhadoresEcdsDatasObservacoes currentExameMarcacaoObservacao = null;
|
||||
|
||||
public TrabalhadoresEcdsDatasEmails currentExameMarcacaoEmail = null;
|
||||
|
||||
public TrabalhadoresEcdsDatas currentExameMarcacao = null;
|
||||
|
||||
public TrabalhadoresEcds currentExame = null;
|
||||
|
||||
public MedicinaProcessoLogic()
|
||||
{
|
||||
try
|
||||
{
|
||||
provider = new MedicinaDAO();
|
||||
} catch( Exception e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { ACTION_STARTUP })
|
||||
public Vector<ColumnizedMappable> getAllEmpresas()
|
||||
{
|
||||
return provider.getAllEmpresas();
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { SELECT_EMPRESA })
|
||||
public Vector<ColumnizedMappable> getEstabelecimentosForEmpresa( Integer empresaID )
|
||||
{
|
||||
return provider.getEstabelecimentosForEmpresa( empresaID );
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { SELECT_ESTABELECIMENTO })
|
||||
public Vector<ColumnizedMappable> getTrabalhadoresForEstabelecimento( Integer estabelecimentoID )
|
||||
{
|
||||
return provider.getTrabalhadoresForEstabelecimento( estabelecimentoID );
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { SELECT_TRABALHADOR })
|
||||
public Trabalhadores getDadosTrabalhador( Integer id )
|
||||
{
|
||||
Trabalhadores result = null;
|
||||
if( id != null )
|
||||
{
|
||||
result = provider.getTrabalhadorByID( id );
|
||||
}
|
||||
currentTrabalhador = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { SELECT_TREE_NODE } )
|
||||
public DefaultMutableTreeNode nodeSelected( DefaultMutableTreeNode node )
|
||||
{
|
||||
String action = null;
|
||||
if( node.getUserObject() == null )
|
||||
{
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresProcesso )
|
||||
{
|
||||
action = SELECT_PROCESSO;
|
||||
currentProcesso = (TrabalhadoresProcesso) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultas )
|
||||
{
|
||||
action = SELECT_CONSULTA;
|
||||
currentConsulta = (TrabalhadoresConsultas) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatas )
|
||||
{
|
||||
action = SELECT_CONSULTA_MARCACAO;
|
||||
currentConsultaMarcacao = (TrabalhadoresConsultasDatas) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasObservacoes )
|
||||
{
|
||||
action = SELECT_CONSULTA_MARCACAO_OBSERVACAO;
|
||||
currentConsultaMarcacaoObservacao = (TrabalhadoresConsultasDatasObservacoes) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasEmails )
|
||||
{
|
||||
action = SELECT_CONSULTA_MARCACAO_EMAIL;
|
||||
currentConsultaMarcacaoEmail = (TrabalhadoresConsultasDatasEmails) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcds )
|
||||
{
|
||||
action = SELECT_EXAME;
|
||||
currentExame = (TrabalhadoresEcds) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatas )
|
||||
{
|
||||
action = SELECT_EXAME_MARCACAO;
|
||||
currentExameMarcacao = (TrabalhadoresEcdsDatas) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasEmails )
|
||||
{
|
||||
action = SELECT_EXAME_MARCACAO_EMAIL;
|
||||
currentExameMarcacaoEmail = (TrabalhadoresEcdsDatasEmails) node.getUserObject();
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasObservacoes )
|
||||
{
|
||||
action = SELECT_EXAME_MARCACAO_OBSERVACAO;
|
||||
currentExameMarcacaoObservacao = (TrabalhadoresEcdsDatasObservacoes) node.getUserObject();
|
||||
}
|
||||
else if( node instanceof FichaAptidaoMutableTreeNode )
|
||||
{
|
||||
action = SELECT_FICHA;
|
||||
currentFicha = (FichaAptidaoMutableTreeNode) node.getUserObject();
|
||||
}
|
||||
runAction( action, node.getUserObject() );
|
||||
return node;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { CREATE_CONSULTA })
|
||||
public TrabalhadoresConsultas createConsulta()
|
||||
{
|
||||
currentConsulta = new TrabalhadoresConsultas();
|
||||
currentConsulta.setToTrabalhadores( currentTrabalhador );
|
||||
currentConsulta.setToTrabalhadoresProcesso( currentProcesso );
|
||||
currentConsulta.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
|
||||
return currentConsulta;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { CREATE_CONSULTA_MARCACAO })
|
||||
public TrabalhadoresConsultasDatas createConsultaMarcacao()
|
||||
{
|
||||
currentConsultaMarcacao = new TrabalhadoresConsultasDatas();
|
||||
currentConsultaMarcacao.setToTrabalhadoresConsultas( currentConsulta );
|
||||
return currentConsultaMarcacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { CREATE_CONSULTA_MARCACAO_EMAIL })
|
||||
public TrabalhadoresConsultasDatasEmails createConsultaMarcacaoEmails()
|
||||
{
|
||||
currentConsultaMarcacaoEmail = new TrabalhadoresConsultasDatasEmails();
|
||||
currentConsultaMarcacaoEmail.setToTrabalhadoresConsultasDatas( currentConsultaMarcacao );
|
||||
currentConsultaMarcacaoEmail.setSubject( " " );
|
||||
currentConsultaMarcacaoEmail.setData( new Date(0) );
|
||||
return currentConsultaMarcacaoEmail;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { CREATE_CONSULTA_MARCACAO_OBSERVACOES })
|
||||
public TrabalhadoresConsultasDatasObservacoes createConsultaMarcacaoObservacoes()
|
||||
{
|
||||
currentConsultaMarcacaoObservacao = new TrabalhadoresConsultasDatasObservacoes();
|
||||
currentConsultaMarcacaoObservacao.setToTrabalhadoresConsultasDatas( currentConsultaMarcacao );
|
||||
return currentConsultaMarcacaoObservacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { CREATE_EXAME })
|
||||
public TrabalhadoresEcds createExame()
|
||||
{
|
||||
currentExame = new TrabalhadoresEcds();
|
||||
currentExame.setToTrabalhadores( currentTrabalhador );
|
||||
currentExame.setToTrabalhadoresProcesso( currentProcesso );
|
||||
currentExame.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
|
||||
return currentExame;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = { SAVE_CONSULTA, SAVE_CONSULTA_MARCACAO, SAVE_CONSULTA_MARCACAO_EMAIL, SAVE_CONSULTA_MARCACAO_OBSERVACOES, SAVE_EXAME, SAVE_EXAME_MARCACAO, SAVE_EXAME_MARCACAO_EMAIL, SAVE_EXAME_MARCACAO_OBSERVACOES })
|
||||
public void saveObject( BaseObject object )
|
||||
{
|
||||
provider.saveObject( object );
|
||||
runAction( REFRESH );
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class LeafButton extends JButton
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public LeafButton(String text)
|
||||
{
|
||||
super( text );
|
||||
setOpaque( false );
|
||||
}
|
||||
|
||||
protected void paintComponent( Graphics g )
|
||||
{
|
||||
boolean pushed = getModel().isPressed();
|
||||
// Color borderColor = getBackground();
|
||||
// Color highlightColor = getBackground();
|
||||
Color textColor = getForeground();
|
||||
Color textAccent = getBackground();
|
||||
Color textAccentHot = getBackground();
|
||||
GradientPaint topGradientUp = new GradientPaint( 0, 0, getBackground().brighter(), 0, getHeight() / 2, getBackground() );
|
||||
GradientPaint topGradientDown = new GradientPaint( 0, 0, getBackground().brighter(), 0, getHeight() / 2, getBackground() );
|
||||
GradientPaint bottomGradientDown = new GradientPaint( 0, getHeight() / 2, getBackground(), 0, getHeight(), getBackground().darker() );
|
||||
GradientPaint bottomGradientUp = new GradientPaint( 0, getHeight() / 2, getBackground(), 0, getHeight(), getBackground().darker().darker() );
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
|
||||
|
||||
int height = getHeight() / 2;
|
||||
|
||||
g2.setPaint( pushed ? topGradientDown : topGradientUp );
|
||||
g2.fillRect( 0, 0, getWidth(), height );
|
||||
|
||||
g2.setPaint( pushed ? bottomGradientDown : bottomGradientUp );
|
||||
g2.fillRect( 0, height, getWidth(), height );
|
||||
|
||||
// g2.setColor( borderColor );
|
||||
// g2.drawRect( 0, 0, getWidth() - 1, getHeight() - 1 );
|
||||
//
|
||||
// g2.setColor( highlightColor );
|
||||
// g2.drawRect( 1, 1, getWidth() - 3, getHeight() - 3 );
|
||||
|
||||
int x = (getWidth() - g2.getFontMetrics().stringWidth( getText() )) / 2;
|
||||
int y = getHeight() - ((getHeight() - g2.getFontMetrics().getHeight()) / 2) - 3;
|
||||
|
||||
y += 1;
|
||||
g2.setColor( pushed ? textAccentHot : textAccent );
|
||||
g2.drawString( getText(), x, y );
|
||||
|
||||
y -= 1;
|
||||
g2.setColor( textColor );
|
||||
g2.drawString( getText(), x, y );
|
||||
// super.paintComponent( g );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,146 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.BevelBorder;
|
||||
|
||||
import com.toedter.calendar.JCalendar;
|
||||
|
||||
public class LeafCalendarDialog extends JDialog
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final int ABOVE = 0;
|
||||
public static final int BELOW = 1;
|
||||
public static final int RIGHT = 0;
|
||||
public static final int LEFT = 1;
|
||||
|
||||
private boolean ok = false;
|
||||
private boolean clear = false;
|
||||
|
||||
Calendar cal = null;
|
||||
|
||||
JComponent parent = null;
|
||||
|
||||
private final JCalendar calendarPanel = new JCalendar( null, null, false, false );
|
||||
protected JPanel extraPanel;
|
||||
|
||||
/** Creates a new instance of JCalendarDialog */
|
||||
public LeafCalendarDialog(JFrame parentFrame, JComponent parent)
|
||||
{
|
||||
super();
|
||||
this.parent = parent;
|
||||
setModal( true );
|
||||
setupComponents();
|
||||
setUndecorated( true );
|
||||
setLocationRelativeTo( parent );
|
||||
setVisible( true );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
GridBagLayout gridbag = new GridBagLayout();
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
getContentPane().setLayout( gridbag );
|
||||
|
||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
constraints.weightx = 1;
|
||||
constraints.gridheight = 1;
|
||||
constraints.weighty = 1;
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
|
||||
gridbag.setConstraints( calendarPanel, constraints );
|
||||
getContentPane().add( calendarPanel );
|
||||
|
||||
LeafButton okButton = new LeafButton( "OK" );
|
||||
okButton.addActionListener( new ActionListener()
|
||||
{
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ok = true;
|
||||
close();
|
||||
}
|
||||
} );
|
||||
LeafButton cancelarButton = new LeafButton( "Cancelar" );
|
||||
cancelarButton.addActionListener( new ActionListener()
|
||||
{
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ok = false;
|
||||
close();
|
||||
}
|
||||
} );
|
||||
LeafButton limparButton = new LeafButton( "Limpar" );
|
||||
limparButton.addActionListener( new ActionListener()
|
||||
{
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ok = false;
|
||||
clear = true;
|
||||
close();
|
||||
}
|
||||
} );
|
||||
|
||||
constraints.gridwidth = 1;
|
||||
constraints.weightx = 0.5;
|
||||
constraints.gridheight = 1;
|
||||
constraints.weighty = 0;
|
||||
constraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gridbag.setConstraints( okButton, constraints );
|
||||
gridbag.setConstraints( cancelarButton, constraints );
|
||||
gridbag.setConstraints( limparButton, constraints );
|
||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
|
||||
getContentPane().add( okButton );
|
||||
getContentPane().add( cancelarButton );
|
||||
getContentPane().add( limparButton );
|
||||
|
||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
constraints.weightx = 1;
|
||||
constraints.gridheight = GridBagConstraints.REMAINDER;
|
||||
constraints.weighty = 0;
|
||||
constraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
extraPanel = new JPanel();
|
||||
gridbag.setConstraints( extraPanel, constraints );
|
||||
getContentPane().add( extraPanel );
|
||||
|
||||
setSize( 250, 250 );
|
||||
|
||||
((JComponent) getContentPane()).setBorder( BorderFactory.createBevelBorder( BevelBorder.RAISED ) );
|
||||
}
|
||||
|
||||
public Date getDate()
|
||||
{
|
||||
Date result = null;
|
||||
if( ok )
|
||||
{
|
||||
cal = Calendar.getInstance();
|
||||
cal.set( Calendar.HOUR_OF_DAY, 12 );
|
||||
cal = calendarPanel.getCalendar();
|
||||
cal.set( Calendar.YEAR, calendarPanel.getYearChooser().getYear() );
|
||||
cal.set( Calendar.DAY_OF_MONTH, calendarPanel.getDayChooser().getDay() );
|
||||
result = cal != null ? cal.getTime() : null;
|
||||
}
|
||||
else if( clear )
|
||||
{
|
||||
result = new Date( 0 );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
setVisible( false );
|
||||
dispose();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class LeafGradientPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public LeafGradientPanel()
|
||||
{
|
||||
setBackground( new Color(200,200,230) );
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void paintComponent( Graphics g )
|
||||
// {
|
||||
// Graphics2D g2d = (Graphics2D) g;
|
||||
// GradientPaint gradientIn = new GradientPaint( 0, 0, getBackground(), getWidth()/2, 0, Color.DARK_GRAY );
|
||||
// g2d.setPaint( gradientIn );
|
||||
// g2d.fillRect( 0, 0, getWidth()/2, getHeight() );
|
||||
//
|
||||
// GradientPaint gradientOut = new GradientPaint( getWidth()/2, 0, Color.DARK_GRAY, getWidth(),0, getBackground() );
|
||||
// g2d.setPaint( gradientOut );
|
||||
// g2d.fillRect( getWidth()/2, 0, getWidth(), getHeight() );
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,284 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class LeafInputField<ObjClass extends Object> extends JTextArea
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final DateFormat sdf = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
|
||||
|
||||
private static final int defaultColorDec = 10;
|
||||
|
||||
private int colorDec = defaultColorDec;
|
||||
|
||||
private Color hot = null;
|
||||
private Color cold = null;
|
||||
private Color background = null;
|
||||
private Color startColor = null;
|
||||
private Color endColor = null;
|
||||
|
||||
private Object selectedOption = null;
|
||||
|
||||
private boolean isError = false;
|
||||
|
||||
private boolean isEditable = false;
|
||||
|
||||
private ObjClass object = null;
|
||||
|
||||
private GradientPaint outerContour= null;
|
||||
private GradientPaint outerReversedContour= null;
|
||||
private GradientPaint innerContour= null;
|
||||
private GradientPaint innerReversedContour = null;
|
||||
private GradientPaint gradient = null;
|
||||
|
||||
public LeafInputField()
|
||||
{
|
||||
super();
|
||||
setOpaque( false );
|
||||
setBorder( BorderFactory.createEmptyBorder( 3, 10, 3, 10 ) );
|
||||
setBackground( Color.WHITE );
|
||||
hot = getBackground();
|
||||
cold = new Color( hot.getRed() > colorDec ? hot.getRed() - colorDec : 0, hot.getGreen() > colorDec ? hot.getGreen() - colorDec : 0, hot.getBlue() > colorDec ? hot.getBlue() - colorDec : 0, hot.getAlpha() );
|
||||
background = cold;
|
||||
this.addFocusListener( new FocusListener()
|
||||
{
|
||||
@Override
|
||||
public void focusLost( FocusEvent e )
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained( FocusEvent e )
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
|
||||
this.addMouseListener( new MouseListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited( MouseEvent e )
|
||||
{
|
||||
// colorDec = defaultColorDec;
|
||||
background = cold;
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered( MouseEvent e )
|
||||
{
|
||||
// colorDec = defaultColorDec + 10;
|
||||
background = hot;
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
ObjClass obj = object;
|
||||
if( obj != null && isEditable )
|
||||
{
|
||||
if( obj instanceof Date )
|
||||
{
|
||||
obj = (ObjClass) getDateFromUser();
|
||||
}
|
||||
else if( obj instanceof Map )
|
||||
{
|
||||
ObjClass out = (ObjClass) getOptionFromUser();
|
||||
selectedOption = out == null ? selectedOption : out;
|
||||
obj = object;
|
||||
}
|
||||
else if( obj instanceof String )
|
||||
{
|
||||
obj = (ObjClass) getStringFromUser();
|
||||
}
|
||||
if( obj != null )
|
||||
{
|
||||
setObject( obj );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
private String getStringFromUser()
|
||||
{
|
||||
LeafTextDialog textDialog = new LeafTextDialog( getParentFrame(), this, (String) object );
|
||||
return textDialog.getText();
|
||||
}
|
||||
|
||||
private Object getOptionFromUser()
|
||||
{
|
||||
LeafOptionDialog optionDialog = new LeafOptionDialog( getParentFrame(), this, (Map) object );
|
||||
return optionDialog.getOption();
|
||||
}
|
||||
|
||||
private Date getDateFromUser()
|
||||
{
|
||||
LeafCalendarDialog calendarDialog = new LeafCalendarDialog( getParentFrame(), this );
|
||||
return calendarDialog.getDate();
|
||||
}
|
||||
|
||||
private JFrame getParentFrame()
|
||||
{
|
||||
if( getRootPane() != null && getRootPane().getParent() instanceof JFrame )
|
||||
{
|
||||
return (JFrame) getRootPane().getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the component to an error state appearance
|
||||
*
|
||||
* @param error
|
||||
*/
|
||||
public void setError( boolean error )
|
||||
{
|
||||
isError = error;
|
||||
}
|
||||
|
||||
public boolean isError()
|
||||
{
|
||||
return isError;
|
||||
}
|
||||
|
||||
protected void paintComponent( Graphics g )
|
||||
{
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
setColors(width, height);
|
||||
|
||||
g2d.setPaint( outerReversedContour );
|
||||
g2d.fillRect( 15, 0, width / 4, height );
|
||||
g2d.setPaint( outerContour );
|
||||
g2d.fillRect( width / 4, 0, width, height );
|
||||
g2d.setPaint( innerReversedContour );
|
||||
g2d.fillRect( 15, 0, width / 4, height - 1 );
|
||||
g2d.setPaint( innerContour );
|
||||
g2d.fillRect( width / 4, 0, width, height - 1 );
|
||||
g2d.setPaint( gradient );
|
||||
g2d.fillRoundRect( 0, 2, width, height - 5, 15, 15 );
|
||||
super.paintComponent( g );
|
||||
}
|
||||
|
||||
private void setColors(int width, int height)
|
||||
{
|
||||
if( startColor == null )
|
||||
{
|
||||
startColor = getGradientStartColor();
|
||||
endColor = getGradientEndColor( startColor );
|
||||
outerContour = new GradientPaint( width / 4, 0, Color.GRAY, width, height, this.getParent().getBackground() );
|
||||
outerReversedContour = new GradientPaint( 15, 0, this.getParent().getBackground(), width / 4, height, Color.GRAY );
|
||||
innerContour = new GradientPaint( width / 4, 0, Color.LIGHT_GRAY,width, height, this.getParent().getBackground() );
|
||||
innerReversedContour = new GradientPaint( 15, 0, this.getParent().getBackground(), width / 4, height, Color.LIGHT_GRAY );
|
||||
gradient = new GradientPaint( 0, 0, startColor, width, height, endColor );
|
||||
}
|
||||
}
|
||||
|
||||
private Color getGradientStartColor()
|
||||
{
|
||||
Color result = background;
|
||||
/*
|
||||
* int red = result.getRed(), green = result.getGreen(), blue =
|
||||
* result.getBlue(), alpha = result.getAlpha(); if( isError() ) { result =
|
||||
* new Color( red, green > colorDec ? (green - colorDec) : 0, (blue >
|
||||
* colorDec) ? (blue - colorDec) : 0, alpha ); } else if( isEditable() ) {
|
||||
* result = new Color( red > colorDec ? (red - colorDec) : 0, green,
|
||||
* blue > colorDec ? (blue - colorDec) : 0, alpha ); }
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
private Color getGradientEndColor( Color startColor )
|
||||
{
|
||||
return getParent() != null ? getParent().getBackground() : startColor;
|
||||
}
|
||||
|
||||
public void setEditable( boolean editable )
|
||||
{
|
||||
isEditable = editable;
|
||||
}
|
||||
|
||||
public boolean isEditable()
|
||||
{
|
||||
return isEditable;
|
||||
}
|
||||
|
||||
public void setSelectedObject( Object key )
|
||||
{
|
||||
selectedOption = key;
|
||||
Object value = null;
|
||||
if( key != null && object instanceof Map )
|
||||
{
|
||||
value = ((Map) object).get( selectedOption );
|
||||
}
|
||||
this.setText( value == null ? " " : value.toString() );
|
||||
}
|
||||
|
||||
public Object getSelectedObject()
|
||||
{
|
||||
return selectedOption;
|
||||
}
|
||||
|
||||
public void setObject( ObjClass object )
|
||||
{
|
||||
this.object = object;
|
||||
if( object != null )
|
||||
{
|
||||
if( object instanceof Date )
|
||||
{
|
||||
this.setText( ((Date) object).getTime() <= 0 ? " " : sdf.format( object ) );
|
||||
}
|
||||
else if( object instanceof Map )
|
||||
{
|
||||
setSelectedObject( selectedOption );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setText( object.toString() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setText( " " );
|
||||
}
|
||||
}
|
||||
|
||||
public ObjClass getObject()
|
||||
{
|
||||
return this.object;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class LeafOptionDialog extends JDialog
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Map<Object, Object> map = null;
|
||||
|
||||
private Object selected = null;
|
||||
|
||||
/** Creates a new instance of JCalendarDialog */
|
||||
public LeafOptionDialog(JFrame parentFrame, JComponent parent, Map<Object, Object> map)
|
||||
{
|
||||
super( parentFrame );
|
||||
this.map = map == null ? new HashMap<Object, Object>() : map;
|
||||
setModal( true );
|
||||
setupComponents();
|
||||
setUndecorated( true );
|
||||
setLocationRelativeTo( parent );
|
||||
setVisible( true );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
Set<Object> keySet = map.keySet();
|
||||
double[] cols = new double[] {
|
||||
TableLayout.MINIMUM
|
||||
};
|
||||
double[] rows = new double[keySet.size() + 1];
|
||||
for( int i = 0; i < keySet.size() + 1; ++i )
|
||||
{
|
||||
rows[i] = TableLayout.MINIMUM;
|
||||
}
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
layout.setVGap( 3 );
|
||||
setContentPane( new LeafGradientPanel() );
|
||||
getContentPane().setLayout( layout );
|
||||
Iterator<Object> iterator = keySet.iterator();
|
||||
Object current = iterator.next();
|
||||
for( int i = 0; i < keySet.size() && iterator.hasNext(); ++i, current = iterator.next() )
|
||||
{
|
||||
LeafInputField<Object> component = new LeafInputField<Object>();
|
||||
component.setObject( map.get( current ) );
|
||||
getContentPane().add( component, new TableLayoutConstraints( 0, i ) );
|
||||
addListenerToComponent( component );
|
||||
}
|
||||
LeafInputField<String> cancelButton = new LeafInputField<String>();
|
||||
cancelButton.setObject( "Cancelar" );
|
||||
getContentPane().add( cancelButton, new TableLayoutConstraints( 0, keySet.size() ) );
|
||||
addListenerToComponent( cancelButton );
|
||||
((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() );
|
||||
setSize( layout.preferredLayoutSize( this.getContentPane() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Object getKeyForValue( Object value )
|
||||
{
|
||||
if( value != null && map.containsValue( value ) )
|
||||
{
|
||||
for( Object key : map.keySet() )
|
||||
{
|
||||
if( map.get( key ).equals( value ) )
|
||||
{
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addListenerToComponent( JComponent component )
|
||||
{
|
||||
component.addMouseListener( new MouseListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited( MouseEvent e )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered( MouseEvent e )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
if( e.getSource() instanceof LeafInputField )
|
||||
{
|
||||
Object value = ((LeafInputField<Object>) e.getSource()).getObject();
|
||||
if( value != null )
|
||||
{
|
||||
selected = getKeyForValue( value );
|
||||
}
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
public Object getOption()
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
setVisible( false );
|
||||
dispose();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class LeafTextArea extends JTextArea
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final int colorDec = 10;
|
||||
|
||||
private boolean isError = false;
|
||||
|
||||
public LeafTextArea(String text)
|
||||
{
|
||||
super( text );
|
||||
setOpaque( false );
|
||||
setMargin( new Insets(3,10,5,10) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the component to an error state appearance
|
||||
*
|
||||
* @param error
|
||||
*/
|
||||
public void setError( boolean error )
|
||||
{
|
||||
isError = error;
|
||||
}
|
||||
|
||||
public boolean isError()
|
||||
{
|
||||
return isError;
|
||||
}
|
||||
|
||||
protected void paintComponent( Graphics g )
|
||||
{
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
Color startColor = getGradientStartColor();
|
||||
Color endColor = getGradientEndColor( startColor );
|
||||
GradientPaint gradient = new GradientPaint( 0, 0, startColor, this.getWidth(), this.getHeight(), endColor );
|
||||
g2d.setPaint( gradient );
|
||||
g2d.fillRoundRect( 0, 0, width, height, 15, 15 );
|
||||
super.paintComponent( g );
|
||||
}
|
||||
|
||||
private Color getGradientStartColor()
|
||||
{
|
||||
Color result = getBackground();
|
||||
return result;
|
||||
}
|
||||
|
||||
private Color getGradientEndColor( Color startColor )
|
||||
{
|
||||
Color result = getParent() != null ? getParent().getBackground() : startColor;
|
||||
int red = result.getRed(), green = result.getGreen(), blue = result.getBlue(), alpha = result.getAlpha();
|
||||
if( isEditable() && isFocusOwner() )
|
||||
{
|
||||
result = new Color( red > colorDec ? red - colorDec : red, green, blue > colorDec ? blue - colorDec : 0, alpha );
|
||||
}
|
||||
else if( isEditable() && isError )
|
||||
{
|
||||
result = new Color( red, green > colorDec ? green - colorDec : green, blue > colorDec ? blue - colorDec : 0, alpha );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditable( boolean editable )
|
||||
{
|
||||
Color bg = this.getBackground();
|
||||
super.setEditable( editable );
|
||||
setBackground( bg );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,156 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class LeafTextDialog extends JDialog
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Dimension buttonSize = new Dimension( 15, 15 );
|
||||
|
||||
private static final Dimension textSize = new Dimension( 150, 15 );
|
||||
|
||||
private static final Dimension expandedTextSize = new Dimension( 100, 200 );
|
||||
|
||||
private String text = null;
|
||||
|
||||
private String defaultText = null;
|
||||
|
||||
private boolean expanded = false;
|
||||
|
||||
private final JTextArea textArea = new JTextArea();
|
||||
private final LeafButton expandButton = new LeafButton( "+" );
|
||||
private final LeafButton okButton = new LeafButton( "Ok" );
|
||||
private final LeafButton cancelButton = new LeafButton( "X" );
|
||||
|
||||
private TableLayout layout = null;
|
||||
private TableLayout expandedLayout = null;
|
||||
|
||||
/** Creates a new instance of JCalendarDialog */
|
||||
public LeafTextDialog(JFrame parentFrame, JComponent parent, String defaultText)
|
||||
{
|
||||
super( parentFrame );
|
||||
this.defaultText = defaultText == null ? "" : defaultText;
|
||||
this.text = this.defaultText;
|
||||
setModal( true );
|
||||
setContentPane( new LeafGradientPanel() );
|
||||
textArea.setText( text );
|
||||
expandButton.setSize( buttonSize );
|
||||
cancelButton.setSize( buttonSize );
|
||||
okButton.setSize( buttonSize );
|
||||
setupLayout();
|
||||
setUndecorated( true );
|
||||
setLocationRelativeTo( parent );
|
||||
expand( expanded );
|
||||
addListeners();
|
||||
setVisible( true );
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED
|
||||
};
|
||||
double[] rows = new double[] {
|
||||
TableLayout.PREFERRED
|
||||
};
|
||||
layout = new TableLayout( cols, rows );
|
||||
|
||||
cols = new double[] {
|
||||
TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED
|
||||
};
|
||||
rows = new double[] {
|
||||
TableLayout.PREFERRED
|
||||
};
|
||||
expandedLayout = new TableLayout( cols, rows );
|
||||
}
|
||||
|
||||
private void placeComponents(boolean expand)
|
||||
{
|
||||
getContentPane().add( expandButton, new TableLayoutConstraints( 0, 0 ) );
|
||||
getContentPane().add( textArea, new TableLayoutConstraints( 1, 0 ) );
|
||||
getContentPane().add( okButton, new TableLayoutConstraints( 2, 0 ) );
|
||||
getContentPane().add( cancelButton, new TableLayoutConstraints( 3, 0 ) );
|
||||
|
||||
((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() );
|
||||
|
||||
setSize( layout.preferredLayoutSize( this.getContentPane() ) );
|
||||
}
|
||||
|
||||
private void setupComponents(boolean expand)
|
||||
{
|
||||
getContentPane().setLayout( expand ? expandedLayout : layout);
|
||||
textArea.setSize( expand ? expandedTextSize : textSize );
|
||||
expandButton.setText( expand ? "-" : "+" );
|
||||
placeComponents(expand);
|
||||
}
|
||||
|
||||
private void expand( boolean expand )
|
||||
{
|
||||
setupComponents(expand);
|
||||
}
|
||||
|
||||
private void addListeners()
|
||||
{
|
||||
expandButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
expanded = !expanded;
|
||||
expand( expanded );
|
||||
}
|
||||
} );
|
||||
|
||||
okButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
text = textArea.getText();
|
||||
close();
|
||||
}
|
||||
} );
|
||||
|
||||
cancelButton.addActionListener( new ActionListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
text = defaultText;
|
||||
close();
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
setVisible( false );
|
||||
dispose();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class LeafTransparentPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private BufferedImage background = null;
|
||||
|
||||
public LeafTransparentPanel()
|
||||
{
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
|
||||
private void updateBackground()
|
||||
{
|
||||
try
|
||||
{
|
||||
Robot rbt = new Robot();
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
Dimension dim = tk.getScreenSize();
|
||||
background = rbt.createScreenCapture( new Rectangle( 0, 0, (int) dim.getWidth(), (int) dim.getHeight() ) );
|
||||
} catch( AWTException ex )
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent( Graphics g )
|
||||
{
|
||||
Point pos = this.getLocationOnScreen();
|
||||
Point offset = new Point( -pos.x, -pos.y );
|
||||
g.drawImage( background, offset.x, offset.y, null );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CLOSE;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
import siprp.logic.SIPRPLogic.LeafUIActionBinding;
|
||||
import siprp.medicina.processo.logic.MedicinaProcessoLogic;
|
||||
import siprp.ui.SIPRPWindow;
|
||||
|
||||
public class MedicinaProcessoWindow extends SIPRPWindow
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Dimension WINDOW_DIMENSION = new Dimension( 1024, 700 );
|
||||
|
||||
public static final String TITLE = "Processos de trabalhadores";
|
||||
|
||||
private static final Dimension DIMENSION_TRABALHADORES_CHOOSER = new Dimension( 0, 200 );
|
||||
private static final Dimension DIMENSION_PROCESSO_TOOLBAR = new Dimension( 150, 0 );
|
||||
|
||||
public final JSeparator separator = new JSeparator();
|
||||
@LeafPanel
|
||||
public final ProcessoDadosPanel panelProcessoDados;
|
||||
@LeafPanel
|
||||
public final ProcessoAccoesPanel panelProcessoToolbar;
|
||||
@LeafPanel
|
||||
public final ProcessoTreePanel panelProcessoTree;
|
||||
@LeafPanel
|
||||
public final TrabalhadoresChooserPanel panelTrabalhadoresChooser;
|
||||
|
||||
public MedicinaProcessoWindow() throws Exception
|
||||
{
|
||||
super( new MedicinaProcessoLogic() );
|
||||
setSize( WINDOW_DIMENSION );
|
||||
setTitle( TITLE );
|
||||
|
||||
panelProcessoDados = new ProcessoDadosPanel( this );
|
||||
panelProcessoToolbar = new ProcessoAccoesPanel( this );
|
||||
panelProcessoTree = new ProcessoTreePanel( this );
|
||||
panelTrabalhadoresChooser = new TrabalhadoresChooserPanel( this );
|
||||
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
completeSetup();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
TableLayout.PREFERRED, TableLayout.FILL, TableLayout.FILL
|
||||
};
|
||||
double[] rows = new double[] {
|
||||
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL
|
||||
};
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
layout.setVGap( 5 );
|
||||
layout.setHGap( 5 );
|
||||
this.setLayout( layout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
panelTrabalhadoresChooser.setPreferredSize( DIMENSION_TRABALHADORES_CHOOSER );
|
||||
panelProcessoToolbar.setPreferredSize( DIMENSION_PROCESSO_TOOLBAR );
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
this.add( panelTrabalhadoresChooser, new TableLayoutConstraints( 0, 0, 2, 0 ) );
|
||||
this.add( separator, new TableLayoutConstraints( 0, 1, 2, 1 ) );
|
||||
this.add( panelProcessoToolbar, new TableLayoutConstraints( 0, 2 ) );
|
||||
this.add( panelProcessoTree, new TableLayoutConstraints( 1, 2 ) );
|
||||
this.add( panelProcessoDados, new TableLayoutConstraints( 2, 2 ) );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action=CLOSE)
|
||||
public void closeWindow()
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,387 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
|
||||
import static info.clearthought.layout.TableLayoutConstants.FILL;
|
||||
import static info.clearthought.layout.TableLayoutConstants.MINIMUM;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CLOSE;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REVERT;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.*;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import siprp.database.cayenne.objects.Trabalhadores;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcds;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
|
||||
import siprp.ui.SIPRPWindow;
|
||||
import siprp.ui.SIPRPWindow.ActionActivation;
|
||||
|
||||
public class ProcessoAccoesPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SIPRPWindow parentWindow;
|
||||
|
||||
private static final String PANEL_START_NAME = "START_PANEL";
|
||||
|
||||
private static final String PANEL_TRABALHADOR_NAME = "TRABALHADOR_PANEL";
|
||||
|
||||
private static final String PANEL_PROCESSO_NAME = "PROCESSO_PANEL";
|
||||
|
||||
private static final String PANEL_CONSULTA_NAME = "PANEL_CONSULTA_NAME";
|
||||
private static final String PANEL_CONSULTA_MARCACAO_NAME = "PANEL_CONSULTA_MARCACAO_NAME";
|
||||
|
||||
private static final String PANEL_EXAME_NAME = "EXAME_PANEL";
|
||||
private static final String PANEL_EXAME_MARCACAO_NAME = "PANEL_EXAME_MARCACAO_NAME";
|
||||
|
||||
private final JPanel cardPanel = new JPanel();
|
||||
|
||||
private final JPanel controlPanel = new JPanel();
|
||||
|
||||
private final CardLayout cardLayout = new CardLayout();
|
||||
|
||||
// panels
|
||||
private final JPanel panelExame = new JPanel();
|
||||
private final JPanel panelExameMarcacao = new JPanel();
|
||||
|
||||
private final JPanel panelConsulta = new JPanel();
|
||||
private final JPanel panelConsultaMarcacao = new JPanel();
|
||||
|
||||
private final JPanel panelProcesso = new JPanel();
|
||||
|
||||
private final JPanel panelTrabalhador = new JPanel();
|
||||
|
||||
private final JPanel panelStart = new JPanel();
|
||||
|
||||
// trabalhador
|
||||
public final LeafButton buttonNovoTrabalhadorProcesso = new LeafButton( "Novo Processo" );
|
||||
|
||||
// processo
|
||||
public final LeafButton buttonFecharProcesso = new LeafButton( "Fechar Processo" );
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA, onChange = "")
|
||||
public final LeafButton buttonNovoProcessoConsulta = new LeafButton( "Nova Consulta" );
|
||||
@ActionActivation(onSelect = CREATE_EXAME, onChange = "")
|
||||
public final LeafButton buttonNovoProcessoExame = new LeafButton( "Novo Exame" );
|
||||
|
||||
// consulta
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonNovoConsultaMarcacao = new LeafButton( "Nova Marca" + ccedil + atilde + "o" );
|
||||
|
||||
// marcacao consulta
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_EMAIL, onChange = "")
|
||||
public final LeafButton buttonNovoConsultaMarcacaoEmail = new LeafButton( "Enviar e-Mail" );
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_OBSERVACOES, onChange = "")
|
||||
public final LeafButton buttonNovoConsultaMarcacaoObservacoes = new LeafButton( "Adicionar Observa" + ccedil + atilde + "o" );
|
||||
|
||||
// email marcacao consulta
|
||||
|
||||
// observacoes marcacao consulta
|
||||
|
||||
// exame
|
||||
public final LeafButton buttonNovoExameMarcacao = new LeafButton( "Nova Marca" + ccedil + atilde + "o" );
|
||||
|
||||
// marcacao exame
|
||||
public final LeafButton buttonNovoExameMarcacaoEmail = new LeafButton( "Enviar e-Mail" );
|
||||
public final LeafButton buttonNovoExameMarcacaoObservacoes = new LeafButton( "Adicionar Observa" + ccedil + atilde + "o" );
|
||||
|
||||
// email marcacao exame
|
||||
|
||||
// observacoes marcacao exame
|
||||
|
||||
// control
|
||||
@ActionActivation(onSelect=SAVE, onChange="")
|
||||
public final LeafButton buttonControlSave = new LeafButton( "Guardar" );
|
||||
@ActionActivation(onSelect=REVERT, onChange="")
|
||||
public final LeafButton buttonControlRevert = new LeafButton( "Reverter" );
|
||||
@ActionActivation(onSelect=CLOSE, onChange="")
|
||||
public final LeafButton buttonControlClose = new LeafButton( "Fechar" );
|
||||
|
||||
private String nextSaveAction = null;
|
||||
|
||||
public ProcessoAccoesPanel(SIPRPWindow parentWindow)
|
||||
{
|
||||
this.parentWindow = parentWindow;
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
TableLayout layout = new TableLayout( new double[] {
|
||||
TableLayout.FILL
|
||||
}, new double[] {
|
||||
TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM
|
||||
} );
|
||||
this.setLayout( layout );
|
||||
|
||||
cardPanel.setLayout( cardLayout );
|
||||
|
||||
layout = new TableLayout( new double[] {
|
||||
TableLayout.FILL, TableLayout.FILL
|
||||
}, new double[] {
|
||||
TableLayout.MINIMUM, TableLayout.MINIMUM
|
||||
} );
|
||||
layout.setVGap( 5 );
|
||||
layout.setHGap( 5 );
|
||||
controlPanel.setLayout( layout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
this.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Ac" + ccedil + otilde + "es" ) );
|
||||
setupStartPanel();
|
||||
setupTrabalhadorPanel();
|
||||
setupProcessoPanel();
|
||||
setupConsultaPanel();
|
||||
setupConsultaMarcacaoPanel();
|
||||
setupExamePanel();
|
||||
setupExameMarcacaoPanel();
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
cardPanel.add( panelStart, PANEL_START_NAME );
|
||||
cardPanel.add( panelTrabalhador, PANEL_TRABALHADOR_NAME );
|
||||
cardPanel.add( panelProcesso, PANEL_PROCESSO_NAME );
|
||||
cardPanel.add( panelConsulta, PANEL_CONSULTA_NAME );
|
||||
cardPanel.add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
cardPanel.add( panelExame, PANEL_EXAME_NAME );
|
||||
cardPanel.add( panelExameMarcacao, PANEL_EXAME_MARCACAO_NAME );
|
||||
|
||||
controlPanel.add( buttonControlSave, new TableLayoutConstraints(0,0) );
|
||||
controlPanel.add( buttonControlRevert, new TableLayoutConstraints(1,0) );
|
||||
controlPanel.add( buttonControlClose, new TableLayoutConstraints(0,1,1,1) );
|
||||
|
||||
this.add( cardPanel, new TableLayoutConstraints( 0, 0 ) );
|
||||
this.add( new JPanel(), new TableLayoutConstraints( 0, 1 ) );
|
||||
this.add( controlPanel, new TableLayoutConstraints( 0, 2 ) );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_TRABALHADOR)
|
||||
public void setForTrabalhador( Trabalhadores trabalhador )
|
||||
{
|
||||
if( trabalhador != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_START_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_PROCESSO)
|
||||
public void setForProcesso( TrabalhadoresProcesso processo )
|
||||
{
|
||||
if( processo != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_PROCESSO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA)
|
||||
public void setForConsulta( TrabalhadoresConsultas consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_CONSULTA_NAME );
|
||||
nextSaveAction = SAVE_CONSULTA;
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO)
|
||||
public void setForConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
nextSaveAction = SAVE_CONSULTA_MARCACAO;
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_EMAIL)
|
||||
public void setForConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
nextSaveAction = SAVE_CONSULTA_MARCACAO_EMAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_OBSERVACAO)
|
||||
public void setForConsultaMarcacaoObservacao( TrabalhadoresConsultasDatasObservacoes obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
nextSaveAction = SAVE_CONSULTA_MARCACAO_OBSERVACOES;
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME)
|
||||
public void setForExame( TrabalhadoresEcds exame )
|
||||
{
|
||||
if( exame != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_EXAME_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO)
|
||||
public void setForExameMarcacao( TrabalhadoresEcdsDatas marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_EXAME_MARCACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_EMAIL)
|
||||
public void setForExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, SELECT_EXAME_MARCACAO );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_OBSERVACAO)
|
||||
public void setForExameMarcacaoObservacao( TrabalhadoresEcdsDatasObservacoes obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, SELECT_EXAME_MARCACAO );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action=SAVE)
|
||||
public void save()
|
||||
{
|
||||
parentWindow.runAction( nextSaveAction );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action=REVERT)
|
||||
public void revert()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void setupStartPanel()
|
||||
{
|
||||
panelStart.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "none" ) );
|
||||
}
|
||||
|
||||
private void setupTrabalhadorPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelTrabalhador, buttonNovoTrabalhadorProcesso, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupProcessoPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelProcesso, buttonFecharProcesso, buttonNovoProcessoConsulta, buttonNovoProcessoExame, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelConsulta, buttonNovoConsultaMarcacao, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelConsultaMarcacao, buttonNovoConsultaMarcacaoEmail, buttonNovoConsultaMarcacaoObservacoes, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupExamePanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelExame, buttonNovoExameMarcacao, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelExameMarcacao, buttonNovoExameMarcacaoEmail, buttonNovoExameMarcacaoObservacoes, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupSimpleActionsPanel( JPanel panel, JComponent... field )
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
FILL
|
||||
};
|
||||
double[] rows = new double[field.length];
|
||||
for( int i = 0; i < field.length; rows[i++] = MINIMUM )
|
||||
;
|
||||
rows[rows.length - 1] = FILL;
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
panel.setLayout( layout );
|
||||
|
||||
for( int i = 0; i < field.length; ++i )
|
||||
{
|
||||
panel.add( field[i], new TableLayoutConstraints( 0, i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,521 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.iacute;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
|
||||
import static info.clearthought.layout.TableLayoutConstants.FILL;
|
||||
import static info.clearthought.layout.TableLayoutConstants.MINIMUM;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.*;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import siprp.database.cayenne.objects.Trabalhadores;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcds;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
|
||||
import siprp.logic.SIPRPLogic.LeafUIActionBinding;
|
||||
import siprp.ui.SIPRPWindow;
|
||||
|
||||
public class ProcessoDadosPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final SIPRPWindow parentWindow;
|
||||
|
||||
private static final String PANEL_START_NAME = "START_PANEL";
|
||||
|
||||
private static final String PANEL_TRABALHADOR_NAME = "TRABALHADOR_PANEL";
|
||||
|
||||
private static final String PANEL_PROCESSO_NAME = "PROCESSO_PANEL";
|
||||
|
||||
private static final String PANEL_CONSULTA_NAME = "PANEL_CONSULTA_NAME";
|
||||
private static final String PANEL_CONSULTA_MARCACAO_NAME = "PANEL_CONSULTA_MARCACAO_NAME";
|
||||
private static final String PANEL_CONSULTA_MARCACAO_EMAIL_NAME = "PANEL_CONSULTA_MARCACAO_EMAIL_NAME";
|
||||
private static final String PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME = "PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME";
|
||||
|
||||
private static final String PANEL_EXAME_NAME = "EXAME_PANEL";
|
||||
private static final String PANEL_EXAME_MARCACAO_NAME = "PANEL_EXAME_MARCACAO_NAME";
|
||||
private static final String PANEL_EXAME_MARCACAO_EMAIL_NAME = "PANEL_EXAME_MARCACAO_EMAIL_NAME";
|
||||
private static final String PANEL_EXAME_MARCACAO_OBSERVACAO_NAME = "PANEL_EXAME_MARCACAO_OBSERVACAO_NAME";
|
||||
|
||||
private final CardLayout cardLayout = new CardLayout();
|
||||
|
||||
// panels
|
||||
private final JPanel panelExame = new JPanel();
|
||||
private final JPanel panelExameMarcacao = new JPanel();
|
||||
private final JPanel panelExameMarcacaoEmail = new JPanel();
|
||||
private final JPanel panelExameMarcacaoObservacao = new JPanel();
|
||||
|
||||
private final JPanel panelConsulta = new JPanel();
|
||||
private final JPanel panelConsultaMarcacao = new JPanel();
|
||||
private final JPanel panelConsultaMarcacaoEmail = new JPanel();
|
||||
private final JPanel panelConsultaMarcacaoObservacao = new JPanel();
|
||||
|
||||
private final JPanel panelProcesso = new JPanel();
|
||||
|
||||
private final JPanel panelTrabalhador = new JPanel();
|
||||
|
||||
private final JPanel panelStart = new JPanel();
|
||||
|
||||
// trabalhador
|
||||
private final JLabel labelTrabalhadorNome = new JLabel( "Nome" );
|
||||
private final JLabel labelTrabalhadorSexo = new JLabel( "Sexo" );
|
||||
private final JLabel labelTrabalhadorDataNascimento = new JLabel( "Data de Nascimento" );
|
||||
private final JLabel labelTrabalhadorNacionalidade = new JLabel( "Nacionalidade" );
|
||||
private final JLabel labelTrabalhadorObservacoes = new JLabel( "Observa" + ccedil + otilde + "es" );
|
||||
|
||||
private final LeafInputField<String> inputTrabalhadorNome = new LeafInputField<String>( );
|
||||
private final LeafInputField<String> inputTrabalhadorSexo = new LeafInputField<String>( );
|
||||
private final LeafInputField<Date> inputTrabalhadorDataNascimento = new LeafInputField<Date>( );
|
||||
private final LeafInputField<String> inputTrabalhadorNacionalidade = new LeafInputField<String>( );
|
||||
private final LeafTextArea inputTrabalhadorObservacoes = new LeafTextArea( "" );
|
||||
|
||||
// processo
|
||||
|
||||
private final JLabel labelProcessoEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelProcessoDataInicio = new JLabel( "In" + iacute + "cio" );
|
||||
private final JLabel labelProcessoDataFim = new JLabel( "Fim" );
|
||||
private final JLabel labelProcessoMotivo = new JLabel( "Motivo" );
|
||||
|
||||
private final LeafInputField<String> inputProcessoEstado = new LeafInputField<String>( );
|
||||
private final LeafInputField<Date> inputProcessoDataInicio = new LeafInputField<Date>( );
|
||||
private final LeafInputField<Date> inputProcessoDataFim = new LeafInputField<Date>( );
|
||||
private final LeafInputField<Integer> inputProcessoMotivo = new LeafInputField<Integer>( );
|
||||
|
||||
// consulta
|
||||
private final JLabel labelConsultaEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelConsultaData = new JLabel( "Data" );
|
||||
|
||||
private final LeafInputField<HashMap<Integer,String>> inputConsultaEstado = new LeafInputField<HashMap<Integer,String>>( );
|
||||
private final LeafInputField<Date> inputConsultaData = new LeafInputField<Date>( );
|
||||
|
||||
// marcacao consulta
|
||||
private final JLabel labelConsultaMarcacaoEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelConsultaMarcacaoData = new JLabel( "Data" );
|
||||
|
||||
private final LeafInputField<HashMap<Integer,String>> inputConsultaMarcacaoEstado = new LeafInputField<HashMap<Integer,String>>( );
|
||||
private final LeafInputField<Date> inputConsultaMarcacaoData = new LeafInputField<Date>( );
|
||||
|
||||
// email marcacao consulta
|
||||
private final JLabel labelConsultaMarcacaoEmailData = new JLabel( "Data" );
|
||||
private final JLabel labelConsultaMarcacaoEmailSubject = new JLabel( "Assunto" );
|
||||
private final JLabel labelConsultaMarcacaoEmailBody = new JLabel( "Mensagem" );
|
||||
|
||||
private final LeafInputField<Date> inputConsultaMarcacaoEmailData = new LeafInputField<Date>( );
|
||||
private final LeafTextArea inputConsultaMarcacaoEmailSubject = new LeafTextArea( "" );
|
||||
private final LeafTextArea inputConsultaMarcacaoEmailBody = new LeafTextArea( "" );
|
||||
|
||||
// observacao marcacao consulta
|
||||
private final LeafTextArea inputConsultaMarcacaoObsMensagem = new LeafTextArea( "" );
|
||||
|
||||
// exame
|
||||
private final JLabel labelExameEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelExameData = new JLabel( "Data" );
|
||||
|
||||
private final LeafInputField<String> inputExameEstado = new LeafInputField<String>( );
|
||||
private final LeafInputField<Date> inputExameData = new LeafInputField<Date>( );
|
||||
|
||||
// marcacao exame
|
||||
private final JLabel labelExameMarcacaoEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelExameMarcacaoData = new JLabel( "Data" );
|
||||
|
||||
private final LeafInputField<String> inputExameMarcacaoEstado = new LeafInputField<String>( );
|
||||
private final LeafInputField<Date> inputExameMarcacaoData = new LeafInputField<Date>( );
|
||||
|
||||
// email marcacao exame
|
||||
private final JLabel labelExameMarcacaoEmailData = new JLabel( "Data" );
|
||||
private final JLabel labelExameMarcacaoEmailSubject = new JLabel( "Assunto" );
|
||||
private final JLabel labelExameMarcacaoEmailBody = new JLabel( "Mensagem" );
|
||||
|
||||
private final LeafInputField<Date> inputExameMarcacaoEmailData = new LeafInputField<Date>( );
|
||||
private final LeafInputField<String> inputExameMarcacaoEmailSubject = new LeafInputField<String>( );
|
||||
private final LeafTextArea inputExameMarcacaoEmailBody = new LeafTextArea( "" );
|
||||
|
||||
// observacao marcacao exame
|
||||
private final LeafTextArea inputExameMarcacaoObsMensagem = new LeafTextArea( "" );
|
||||
|
||||
public ProcessoDadosPanel(SIPRPWindow parentWindow)
|
||||
{
|
||||
this.parentWindow = parentWindow;
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
this.setLayout( cardLayout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
setupStartPanel();
|
||||
setupTrabalhadorPanel();
|
||||
setupProcessoPanel();
|
||||
setupConsultaPanel();
|
||||
setupConsultaMarcacaoPanel();
|
||||
setupConsultaMarcacaoEmailPanel();
|
||||
setupConsultaMarcacaoObservacoesPanel();
|
||||
setupExamePanel();
|
||||
setupExameMarcacaoPanel();
|
||||
setupExameMarcacaoEmailPanel();
|
||||
setupExameMarcacaoObservacoesPanel();
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
add( panelStart, PANEL_START_NAME );
|
||||
add( panelTrabalhador, PANEL_TRABALHADOR_NAME );
|
||||
add( panelProcesso, PANEL_PROCESSO_NAME );
|
||||
add( panelConsulta, PANEL_CONSULTA_NAME );
|
||||
add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
add( panelConsultaMarcacaoEmail, PANEL_CONSULTA_MARCACAO_EMAIL_NAME );
|
||||
add( panelConsultaMarcacaoObservacao, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME );
|
||||
add( panelExame, PANEL_EXAME_NAME );
|
||||
add( panelExameMarcacao, PANEL_EXAME_MARCACAO_NAME );
|
||||
add( panelExameMarcacaoEmail, PANEL_EXAME_MARCACAO_EMAIL_NAME );
|
||||
add( panelExameMarcacaoObservacao, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_TRABALHADOR)
|
||||
public void setForTrabalhador( Trabalhadores trabalhador )
|
||||
{
|
||||
if( trabalhador != null )
|
||||
{
|
||||
inputTrabalhadorDataNascimento.setObject( trabalhador.getDataNascimento() );
|
||||
inputTrabalhadorSexo.setObject( trabalhador.getSexo() );
|
||||
inputTrabalhadorNome.setObject( trabalhador.getNome() );
|
||||
inputTrabalhadorNacionalidade.setObject( trabalhador.getNacionalidade() );
|
||||
inputTrabalhadorObservacoes.setText( trabalhador.getObservacoes() );
|
||||
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_START_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_PROCESSO)
|
||||
public void setForProcesso( TrabalhadoresProcesso processo )
|
||||
{
|
||||
if( processo != null )
|
||||
{
|
||||
inputProcessoDataFim.setObject( processo.getDataFim());
|
||||
inputProcessoDataInicio.setObject( processo.getDataInicio() );
|
||||
inputProcessoEstado.setObject( processo.getEstado() );
|
||||
inputProcessoMotivo.setObject( processo.getMotivo() );
|
||||
|
||||
cardLayout.show( this, PANEL_PROCESSO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA)
|
||||
public void setForConsulta( TrabalhadoresConsultas consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
inputConsultaEstado.setObject( consulta.getConsultaEstados() );
|
||||
inputConsultaEstado.setSelectedObject( consulta.getEstado() );
|
||||
inputConsultaData.setObject( consulta.getData() == null ? new Date(0) : consulta.getData() );
|
||||
|
||||
// inputConsultaData.setError( consulta.getData() == null || consulta.getData().equals( new Date(0) ) );
|
||||
|
||||
cardLayout.show( this, PANEL_CONSULTA_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO)
|
||||
public void setForConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
inputConsultaMarcacaoData.setObject( marcacao.getData() );
|
||||
inputConsultaMarcacaoEstado.setObject( marcacao.getConsultaEstados() );
|
||||
inputConsultaMarcacaoEstado.setSelectedObject( marcacao.getEstado() );
|
||||
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_EMAIL)
|
||||
public void setForConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
inputConsultaMarcacaoEmailBody.setText( email.getBody() );
|
||||
inputConsultaMarcacaoEmailSubject.setText( email.getSubject() );
|
||||
inputConsultaMarcacaoEmailData.setObject( email.getData() );
|
||||
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_EMAIL_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_OBSERVACAO)
|
||||
public void setForConsultaMarcacaoObs( TrabalhadoresConsultasDatasObservacoes obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
inputConsultaMarcacaoObsMensagem.setText( obs.getObservacao() );
|
||||
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME)
|
||||
public void setForExame( TrabalhadoresEcds exame )
|
||||
{
|
||||
if( exame != null )
|
||||
{
|
||||
inputExameData.setText( exame.getDataString() );
|
||||
inputExameEstado.setText( exame.getEstadoString() );
|
||||
cardLayout.show( this, PANEL_EXAME_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO)
|
||||
public void setForExameMarcacao( TrabalhadoresEcdsDatas exameMarcacao )
|
||||
{
|
||||
if( exameMarcacao != null )
|
||||
{
|
||||
inputExameMarcacaoData.setText( exameMarcacao.getDataString() );
|
||||
inputExameMarcacaoEstado.setText( exameMarcacao.getEstadoString() );
|
||||
cardLayout.show( this, PANEL_EXAME_MARCACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_EMAIL)
|
||||
public void setForExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
inputExameMarcacaoEmailBody.setText( email.getBody() );
|
||||
inputExameMarcacaoEmailSubject.setText( email.getSubject() );
|
||||
inputExameMarcacaoEmailData.setText( email.getDataString() );
|
||||
cardLayout.show( this, PANEL_EXAME_MARCACAO_EMAIL_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_OBSERVACAO)
|
||||
public void setForExameMarcacaoObs( TrabalhadoresEcdsDatasObservacoes obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
inputExameMarcacaoObsMensagem.setText( obs.getObservacao() );
|
||||
cardLayout.show( this, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA)
|
||||
public void setForNewConsulta( TrabalhadoresConsultas consulta )
|
||||
{
|
||||
inputConsultaData.setEditable( true );
|
||||
inputConsultaEstado.setEditable( true );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO)
|
||||
public void setForNewConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
|
||||
{
|
||||
inputConsultaMarcacaoData.setEditable( true );
|
||||
inputConsultaMarcacaoEstado.setEditable( true );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL)
|
||||
public void setForNewConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
|
||||
{
|
||||
inputConsultaMarcacaoEmailBody.setEditable( true );
|
||||
inputConsultaMarcacaoEmailData.setEditable( true );
|
||||
inputConsultaMarcacaoEmailSubject.setEditable( true );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public void setForNewConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes )
|
||||
{
|
||||
inputConsultaMarcacaoObsMensagem.setEditable( true );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_CONSULTA)
|
||||
public void updateToSaveConsulta( TrabalhadoresConsultas consulta )
|
||||
{
|
||||
consulta.setData( inputConsultaData.getObject() );
|
||||
consulta.setEstado( (Integer) inputConsultaEstado.getSelectedObject() );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO)
|
||||
public void updateToSaveConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
|
||||
{
|
||||
marcacao.setData( inputConsultaMarcacaoData.getObject() );
|
||||
marcacao.setEstado( (Integer) inputConsultaMarcacaoEstado.getSelectedObject() );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_EMAIL)
|
||||
public void updateToSaveConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
|
||||
{
|
||||
email.setBody( inputConsultaMarcacaoEmailBody.getText() );
|
||||
email.setData( inputConsultaMarcacaoEmailData.getObject() );
|
||||
email.setSubject( inputConsultaMarcacaoEmailSubject.getText() );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public void updateToSaveConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes )
|
||||
{
|
||||
observacoes.setObservacao( inputConsultaMarcacaoObsMensagem.getText() );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME)
|
||||
public void setForNewExame( TrabalhadoresEcds exame )
|
||||
{
|
||||
inputExameData.setEditable( true );
|
||||
inputExameEstado.setEditable( true );
|
||||
}
|
||||
|
||||
private void setupStartPanel()
|
||||
{
|
||||
}
|
||||
|
||||
private void setupSimpleDataPanel( JPanel panel, String name, JComponent... field )
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
FILL
|
||||
};
|
||||
double[] rows = new double[field.length];
|
||||
for( int i = 0; i < field.length; rows[i++] = MINIMUM )
|
||||
;
|
||||
rows[rows.length - 1] = FILL;
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
layout.setHGap( 5 );
|
||||
layout.setVGap( 5 );
|
||||
panel.setLayout( layout );
|
||||
if( name != null )
|
||||
{
|
||||
panel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), name ) );
|
||||
}
|
||||
|
||||
for( int i = 0; i < field.length; ++i )
|
||||
{
|
||||
panel.add( field[i], new TableLayoutConstraints( 0, i ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void setupTrabalhadorPanel()
|
||||
{
|
||||
inputTrabalhadorNacionalidade.setEditable( false );
|
||||
inputTrabalhadorDataNascimento.setEditable( false );
|
||||
inputTrabalhadorNome.setEditable( false );
|
||||
inputTrabalhadorSexo.setEditable( false );
|
||||
inputTrabalhadorObservacoes.setEditable( false );
|
||||
setupSimpleDataPanel( panelTrabalhador, "Trabalhador", labelTrabalhadorNome, inputTrabalhadorNome, labelTrabalhadorSexo, inputTrabalhadorSexo, labelTrabalhadorNacionalidade, inputTrabalhadorNacionalidade, labelTrabalhadorDataNascimento, inputTrabalhadorDataNascimento, labelTrabalhadorObservacoes, inputTrabalhadorObservacoes );
|
||||
}
|
||||
|
||||
private void setupProcessoPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelProcesso, "Processo", labelProcessoEstado, inputProcessoEstado, labelProcessoDataInicio, inputProcessoDataInicio, labelProcessoDataFim, inputProcessoDataFim, labelProcessoMotivo, inputProcessoMotivo, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelConsulta, "Consulta", labelConsultaEstado, inputConsultaEstado, labelConsultaData, inputConsultaData, new JPanel() );
|
||||
inputConsultaEstado.setEditable( true );
|
||||
inputConsultaData.setEditable( true );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelConsultaMarcacao, "Marca" + ccedil + atilde + "o de Consulta", labelConsultaMarcacaoEstado, inputConsultaMarcacaoEstado, labelConsultaMarcacaoData, inputConsultaMarcacaoData, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoEmailPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelConsultaMarcacaoEmail, "Email", labelConsultaMarcacaoEmailData, inputConsultaMarcacaoEmailData, labelConsultaMarcacaoEmailSubject, inputConsultaMarcacaoEmailSubject, labelConsultaMarcacaoEmailBody, inputConsultaMarcacaoEmailBody );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoObservacoesPanel()
|
||||
{
|
||||
inputConsultaMarcacaoObsMensagem.setEditable( false );
|
||||
setupSimpleDataPanel( panelConsultaMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputConsultaMarcacaoObsMensagem );
|
||||
}
|
||||
|
||||
private void setupExamePanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelExame, "Exame", labelExameEstado, inputExameEstado, labelExameData, inputExameData, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelExameMarcacao, "Marca" + ccedil + atilde + "o de Exame", labelExameMarcacaoEstado, inputExameMarcacaoEstado, labelExameMarcacaoData, inputExameMarcacaoData, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoEmailPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelExameMarcacaoEmail, "Email", labelExameMarcacaoEmailData, inputExameMarcacaoEmailData, labelExameMarcacaoEmailSubject, inputExameMarcacaoEmailSubject, labelExameMarcacaoEmailBody, inputExameMarcacaoEmailBody );
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoObservacoesPanel()
|
||||
{
|
||||
inputExameMarcacaoObsMensagem.setEditable( false );
|
||||
setupSimpleDataPanel( panelExameMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputExameMarcacaoObsMensagem );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,324 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.*;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TREE_NODE;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import org.apache.cayenne.CayenneDataObject;
|
||||
|
||||
import siprp.database.cayenne.objects.Trabalhadores;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcds;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes;
|
||||
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
|
||||
import siprp.logic.SIPRPLogic.LeafUIActionBinding;
|
||||
import siprp.medicina.MarcacaoConsultaExtendedPanel;
|
||||
import siprp.medicina.processo.ProcessoDataProvider;
|
||||
import siprp.medicina.processo.estrutura.ConsultaMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.DataMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.ECDsMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.EstruturaProcessoRenderer;
|
||||
import siprp.medicina.processo.estrutura.MailMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.MarcacaoMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.ObservacoesMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.ProcessoMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.TrabalhadorMutableTreeNode;
|
||||
import siprp.ui.SIPRPWindow;
|
||||
import siprp.ui.SIPRPWindow.ActionActivation;
|
||||
|
||||
public class ProcessoTreePanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SIPRPWindow parentWindow;
|
||||
|
||||
private final JScrollPane mainScroll = new JScrollPane();;
|
||||
|
||||
protected TrabalhadorMutableTreeNode rootNode;
|
||||
|
||||
private final Map<CayenneDataObject, DefaultMutableTreeNode> nodeByObject = new HashMap<CayenneDataObject, DefaultMutableTreeNode>();
|
||||
|
||||
@ActionActivation(onSelect = SELECT_TREE_NODE, onChange = "")
|
||||
public JTree mainTree;
|
||||
|
||||
protected ProcessoDataProvider provider;
|
||||
|
||||
public ProcessoTreePanel(SIPRPWindow parentWindow)
|
||||
{
|
||||
super();
|
||||
this.parentWindow = parentWindow;
|
||||
try
|
||||
{
|
||||
provider = ProcessoDataProvider.getProvider();
|
||||
} catch( Exception e )
|
||||
{
|
||||
provider = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
TableLayout.FILL
|
||||
};
|
||||
double[] rows = new double[] {
|
||||
TableLayout.FILL
|
||||
};
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
this.setLayout( layout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
this.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Processos" ) );
|
||||
mainScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
|
||||
mainScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
|
||||
rootNode = new TrabalhadorMutableTreeNode( "" );
|
||||
mainTree = new JTree( rootNode );
|
||||
mainTree.setExpandsSelectedPaths( true );
|
||||
mainTree.setCellRenderer( new EstruturaProcessoRenderer() );
|
||||
mainScroll.setViewportView( mainTree );
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
this.add( mainScroll, new TableLayoutConstraints( 0, 0 ) );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_TRABALHADOR)
|
||||
public void setTrabalhador( Trabalhadores trabalhador )
|
||||
{
|
||||
clear();
|
||||
if( trabalhador == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
rootNode.setUserObject( trabalhador );
|
||||
List<DefaultMutableTreeNode> nodes = loadProcessos( trabalhador );
|
||||
for( DefaultMutableTreeNode node : nodes )
|
||||
{
|
||||
addNodeTo( node, rootNode );
|
||||
}
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
|
||||
int count = mainTree.getRowCount();
|
||||
for( int n = count - 1; n >= 0; n-- )
|
||||
{
|
||||
mainTree.expandRow( n );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA)
|
||||
public void createConsultaNode( TrabalhadoresConsultas consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( consulta.getToTrabalhadoresProcesso() );
|
||||
ConsultaMutableTreeNode node = new ConsultaMutableTreeNode( consulta );
|
||||
node.setData( consulta.getData() );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO)
|
||||
public void createConsultaMarcacaoNode( TrabalhadoresConsultasDatas marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( marcacao.getToTrabalhadoresConsultas() );
|
||||
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL)
|
||||
public void createConsultaMarcacaoEmailNode( TrabalhadoresConsultasDatasEmails email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( email.getToTrabalhadoresConsultasDatas() );
|
||||
MailMutableTreeNode node = new MailMutableTreeNode( email );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public void createConsultaMarcacaoObservacoesNode( TrabalhadoresConsultasDatasObservacoes observacoes )
|
||||
{
|
||||
if( observacoes != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( observacoes.getToTrabalhadoresConsultasDatas() );
|
||||
ObservacoesMutableTreeNode node = new ObservacoesMutableTreeNode( observacoes );
|
||||
addNodeTo( node, parentNode );
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
|
||||
mainTree.setSelectionPath( new TreePath( node.getPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME)
|
||||
public void createExameNode( TrabalhadoresEcds exame )
|
||||
{
|
||||
if( exame != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( exame.getToTrabalhadoresProcesso() );
|
||||
ECDsMutableTreeNode node = new ECDsMutableTreeNode( exame );
|
||||
node.setData( exame.getData() );
|
||||
addNodeTo( node, parentNode );
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
|
||||
mainTree.setSelectionPath( new TreePath( node.getPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected List<DefaultMutableTreeNode> loadProcessos( Trabalhadores trabalhador )
|
||||
{
|
||||
List<DefaultMutableTreeNode> result = new ArrayList<DefaultMutableTreeNode>();
|
||||
List<TrabalhadoresProcesso> processos = trabalhador.getTrabalhadoresProcessoArray();
|
||||
for( TrabalhadoresProcesso trabalhadoresProcesso : processos )
|
||||
{
|
||||
result.add( loadProcesso( trabalhadoresProcesso ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ProcessoMutableTreeNode loadProcesso( TrabalhadoresProcesso processo )
|
||||
{
|
||||
ProcessoMutableTreeNode node = new ProcessoMutableTreeNode( processo );
|
||||
node.removeAllChildren();
|
||||
for( TrabalhadoresConsultas current : (List<TrabalhadoresConsultas>) processo.getTrabalhadoresConsultasArray() )
|
||||
{
|
||||
addNodeTo( loadConsulta( current ), node );
|
||||
}
|
||||
for( TrabalhadoresEcds current : (List<TrabalhadoresEcds>) processo.getTrabalhadoresEcdsArray() )
|
||||
{
|
||||
addNodeTo( loadExame( current ), node );
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
private ECDsMutableTreeNode loadExame( TrabalhadoresEcds exame )
|
||||
{
|
||||
ECDsMutableTreeNode node = new ECDsMutableTreeNode( exame );
|
||||
node.setData( exame.getData() );
|
||||
node.removeAllChildren();
|
||||
List<TrabalhadoresEcdsDatas> marcacoes = exame.getTrabalhadoresEcdsDatasArray();
|
||||
for( TrabalhadoresEcdsDatas marcacao : marcacoes )
|
||||
{
|
||||
addNodeTo( loadExameMarcacao( marcacao ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private DataMutableTreeNode loadExameMarcacao( TrabalhadoresEcdsDatas marcacao )
|
||||
{
|
||||
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
|
||||
for( TrabalhadoresEcdsDatasEmails email : (List<TrabalhadoresEcdsDatasEmails>) marcacao.getTrabalhadoresEcdsDatasEmailsArray() )
|
||||
{
|
||||
addNodeTo( new MailMutableTreeNode( email ), node );
|
||||
}
|
||||
for( TrabalhadoresEcdsDatasObservacoes observacoes : (List<TrabalhadoresEcdsDatasObservacoes>) marcacao.getTrabalhadoresEcdsDatasObservacoesArray() )
|
||||
{
|
||||
addNodeTo( new ObservacoesMutableTreeNode( observacoes ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private ConsultaMutableTreeNode loadConsulta( TrabalhadoresConsultas consulta )
|
||||
{
|
||||
ConsultaMutableTreeNode node = new ConsultaMutableTreeNode( consulta );
|
||||
node.setData( consulta.getData() );
|
||||
node.removeAllChildren();
|
||||
List<TrabalhadoresConsultasDatas> marcacoes = consulta.getTrabalhadoresConsultasDatasArray();
|
||||
for( TrabalhadoresConsultasDatas marcacao : marcacoes )
|
||||
{
|
||||
addNodeTo( loadMarcacao( marcacao ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private DataMutableTreeNode loadMarcacao( TrabalhadoresConsultasDatas marcacao )
|
||||
{
|
||||
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
|
||||
for( TrabalhadoresConsultasDatasEmails email : (List<TrabalhadoresConsultasDatasEmails>) marcacao.getTrabalhadoresConsultasDatasEmailsArray() )
|
||||
{
|
||||
addNodeTo( new MailMutableTreeNode( email ), node );
|
||||
}
|
||||
for( TrabalhadoresConsultasDatasObservacoes observacoes : (List<TrabalhadoresConsultasDatasObservacoes>) marcacao.getTrabalhadoresConsultasDatasObservacoesArray() )
|
||||
{
|
||||
addNodeTo( new ObservacoesMutableTreeNode( observacoes ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private void addNodeTo( DefaultMutableTreeNode node, DefaultMutableTreeNode to )
|
||||
{
|
||||
if( node.getUserObject() != null && node.getUserObject() instanceof CayenneDataObject )
|
||||
{
|
||||
nodeByObject.put( (CayenneDataObject) node.getUserObject(), node );
|
||||
}
|
||||
to.add( node );
|
||||
}
|
||||
|
||||
private void addAndRefresh( DefaultMutableTreeNode node, DefaultMutableTreeNode parentNode )
|
||||
{
|
||||
addNodeTo( node, parentNode );
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
|
||||
mainTree.setSelectionPath( new TreePath( node.getPath() ) );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = REFRESH)
|
||||
public void refresh()
|
||||
{
|
||||
DefaultMutableTreeNode selected = getSelectedNode();
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
|
||||
if( selected != null )
|
||||
{
|
||||
mainTree.setSelectionPath( new TreePath( selected.getPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private DefaultMutableTreeNode getSelectedNode()
|
||||
{
|
||||
DefaultMutableTreeNode result = null;
|
||||
Object[] nodes = mainTree.getSelectionPath().getPath();
|
||||
if( nodes != null && nodes.length > 0 && nodes[nodes.length - 1] instanceof DefaultMutableTreeNode )
|
||||
{
|
||||
result = (DefaultMutableTreeNode) nodes[nodes.length - 1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
mainTree.clearSelection();
|
||||
mainTree.setRootVisible( true );
|
||||
rootNode.removeAllChildren();
|
||||
// PROCESSOS_POR_ID.clear();
|
||||
rootNode.setUserObject( "" );
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static siprp.logic.SIPRPLogic.ACTION_STARTUP;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EMPRESA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_ESTABELECIMENTO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import siprp.logic.SIPRPLogic.LeafUIActionBinding;
|
||||
import siprp.ui.SIPRPWindow;
|
||||
import siprp.ui.SIPRPWindow.ActionActivation;
|
||||
|
||||
import com.evolute.utils.tables.BaseTable;
|
||||
import com.evolute.utils.tables.ColumnizedMappable;
|
||||
import com.evolute.utils.tables.VectorTableModel;
|
||||
|
||||
public class TrabalhadoresChooserPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SIPRPWindow parentWindow;
|
||||
|
||||
@ActionActivation(onSelect = SELECT_EMPRESA, onChange = "")
|
||||
public BaseTable empresasTable;
|
||||
public VectorTableModel empresasModel;
|
||||
|
||||
@ActionActivation(onSelect = SELECT_ESTABELECIMENTO, onChange = "")
|
||||
public BaseTable estabelecimentosTable;
|
||||
public VectorTableModel estabelecimentosModel;
|
||||
|
||||
@ActionActivation(onSelect = SELECT_TRABALHADOR, onChange = "")
|
||||
public BaseTable trabalhadoresTable;
|
||||
public VectorTableModel trabalhadoresModel;
|
||||
|
||||
public TrabalhadoresChooserPanel(SIPRPWindow parentWindow)
|
||||
{
|
||||
super();
|
||||
this.parentWindow = parentWindow;
|
||||
|
||||
setupComponents();
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
empresasModel = new VectorTableModel( new String[] {
|
||||
"empresas"
|
||||
} );
|
||||
empresasTable = new BaseTable( empresasModel );
|
||||
empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
empresasTable.setNonResizableNorReordable();
|
||||
JScrollPane empresasScroll = new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
estabelecimentosModel = new VectorTableModel( new String[] {
|
||||
"estabelecimentos"
|
||||
} );
|
||||
estabelecimentosTable = new BaseTable( estabelecimentosModel );
|
||||
estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
estabelecimentosTable.setNonResizableNorReordable();
|
||||
JScrollPane estabelecimentosScroll = new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
trabalhadoresModel = new VectorTableModel( new String[] {
|
||||
"trabalhadores"
|
||||
} );
|
||||
trabalhadoresTable = new BaseTable( trabalhadoresModel );
|
||||
trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
trabalhadoresTable.setNonResizableNorReordable();
|
||||
JScrollPane trabalhadoresScroll = new JScrollPane( trabalhadoresTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
|
||||
GridBagLayout gridbag = new GridBagLayout();
|
||||
setLayout( gridbag );
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
constraints.insets = new Insets( 1, 1, 1, 1 );
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
constraints.gridwidth = 1;
|
||||
constraints.gridheight = 1;
|
||||
constraints.weightx = 0.3;
|
||||
constraints.weighty = 1;
|
||||
|
||||
gridbag.setConstraints( empresasScroll, constraints );
|
||||
|
||||
gridbag.setConstraints( estabelecimentosScroll, constraints );
|
||||
|
||||
constraints.weightx = 0.4;
|
||||
constraints.gridheight = GridBagConstraints.REMAINDER;
|
||||
gridbag.setConstraints( trabalhadoresScroll, constraints );
|
||||
|
||||
add( empresasScroll );
|
||||
add( estabelecimentosScroll );
|
||||
add( trabalhadoresScroll );
|
||||
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action= ACTION_STARTUP)
|
||||
public void fillEmpresas( Vector<ColumnizedMappable> allEmpresas )
|
||||
{
|
||||
empresasTable.clearSelection();
|
||||
empresasModel.clearAll();
|
||||
if( allEmpresas != null )
|
||||
{
|
||||
empresasModel.setValues( allEmpresas );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EMPRESA)
|
||||
public void fillEstablecimentos( Vector<ColumnizedMappable> allEstabelecimentos )
|
||||
{
|
||||
estabelecimentosTable.clearSelection();
|
||||
estabelecimentosModel.clearAll();
|
||||
if( allEstabelecimentos != null )
|
||||
{
|
||||
estabelecimentosModel.setValues( allEstabelecimentos );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_ESTABELECIMENTO)
|
||||
public void fillTrabalhadores( Vector<ColumnizedMappable> allTrabalhadores )
|
||||
{
|
||||
trabalhadoresTable.clearSelection();
|
||||
trabalhadoresModel.clearAll();
|
||||
if( allTrabalhadores != null )
|
||||
{
|
||||
trabalhadoresModel.setValues( allTrabalhadores );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,622 @@
|
||||
package siprp.ui;
|
||||
|
||||
import static siprp.logic.SIPRPLogic.ACTION_STARTUP;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import siprp.logic.SIPRPLogic;
|
||||
import siprp.logic.SIPRPLogic.Action;
|
||||
import siprp.logic.SIPRPLogic.LeafLogicActionBinding;
|
||||
import siprp.logic.SIPRPLogic.LeafUIActionBinding;
|
||||
|
||||
import com.evolute.utils.tables.BaseTable;
|
||||
import com.evolute.utils.tables.ColumnizedMappable;
|
||||
import com.evolute.utils.tables.VectorTableModel;
|
||||
import com.evolute.utils.tracker.TrackableWindow;
|
||||
|
||||
public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectionListener, TreeSelectionListener, ActionListener
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Registers DataComponent in a list of actions
|
||||
*
|
||||
* @author tsimao
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ActionActivation
|
||||
{
|
||||
/**
|
||||
* Array of actions to execute when a select is listened in this
|
||||
* JComponent
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String onSelect();
|
||||
|
||||
/**
|
||||
* Array of actions to execute when a change is listened in this
|
||||
* JComponent
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String onChange();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds data fields to actions
|
||||
*
|
||||
* @author tsimao
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LeafObject
|
||||
{
|
||||
|
||||
/**
|
||||
* Actions that update this field
|
||||
*/
|
||||
String useWithAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares a JPanel as a leaf
|
||||
*
|
||||
* @author tsimao
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LeafPanel
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This window's logic controller
|
||||
*/
|
||||
private final SIPRPLogic logicController;
|
||||
|
||||
private List<JPanel> subPanels = new ArrayList<JPanel>();
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
private Map<String, Action> mapActionByName = new HashMap<String, Action>();
|
||||
|
||||
/**
|
||||
* Fields
|
||||
*/
|
||||
private Map<String, Object> mapWindowOnSelectFieldByActionName = new HashMap<String, Object>();
|
||||
private Map<String, Object> mapWindowOnChangeFieldByActionName = new HashMap<String, Object>();
|
||||
private Map<String, Field> mapLeafObjectByActionName = new HashMap<String, Field>();
|
||||
private Map<Field, Object> mapInstanceByField = new HashMap<Field, Object>();
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
private Map<String, List<Method>> mapWindowMethodsByActionName = new HashMap<String, List<Method>>();
|
||||
private Map<String, Method> mapLogicMethodByActionName = new HashMap<String, Method>();
|
||||
private Map<Method, Object> mapInstanceByMethod = new HashMap<Method, Object>();
|
||||
|
||||
/**
|
||||
* Meta-info
|
||||
*/
|
||||
private Map<Object, Annotation> mapAnnotationByObject = new HashMap<Object, Annotation>();
|
||||
|
||||
public SIPRPWindow(SIPRPLogic logicController) throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
super();
|
||||
this.logicController = logicController;
|
||||
if( logicController != null )
|
||||
{
|
||||
logicController.addWindow( this );
|
||||
}
|
||||
}
|
||||
|
||||
public void completeSetup()
|
||||
{
|
||||
try
|
||||
{
|
||||
loadLeafs();
|
||||
loadActions();
|
||||
loadFields();
|
||||
loadMethods();
|
||||
runAction( ACTION_STARTUP, null );
|
||||
} catch( Exception e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLeafs() throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
Field fields[] = this.getClass().getDeclaredFields();
|
||||
if( fields != null )
|
||||
{
|
||||
for( Field field : fields )
|
||||
{
|
||||
if( field.getAnnotation( LeafPanel.class ) != null && field.get( this ) != null )
|
||||
{
|
||||
subPanels.add( (JPanel) field.get( this ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadActions() throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
Field[] allLogicFields = this.logicController.getClass().getFields();
|
||||
for( Field field : allLogicFields )
|
||||
{
|
||||
Action action = field.getAnnotation( Action.class );
|
||||
if( action != null )
|
||||
{
|
||||
String value = (String) field.get( this );
|
||||
if( value != null )
|
||||
{
|
||||
mapActionByName.put( value, action );
|
||||
mapWindowMethodsByActionName.put( value, new ArrayList<Method>() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFields( Field[] fields, Object instance )
|
||||
{
|
||||
try
|
||||
{
|
||||
for( Field field : fields )
|
||||
{
|
||||
ActionActivation componentBehaviour = field.getAnnotation( ActionActivation.class );
|
||||
if( componentBehaviour != null )
|
||||
{
|
||||
String onChange = componentBehaviour.onChange();
|
||||
// if( onChange != null )
|
||||
// {
|
||||
// for( String currentOnChange : onChange )
|
||||
// {
|
||||
if( mapActionByName.containsKey( onChange ) )
|
||||
{
|
||||
// valid action
|
||||
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
|
||||
mapWindowOnChangeFieldByActionName.put( onChange, field.get( instance ) );
|
||||
mapInstanceByField.put( field, instance );
|
||||
addListenerForField( componentBehaviour, field, instance );
|
||||
}
|
||||
// }
|
||||
// }
|
||||
String onSelect = componentBehaviour.onSelect();
|
||||
// if( onSelect != null )
|
||||
// {
|
||||
// for( String currentOnSelect : onSelect )
|
||||
// {
|
||||
if( mapActionByName.containsKey( onSelect ) )
|
||||
{
|
||||
// valid action
|
||||
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
|
||||
mapWindowOnSelectFieldByActionName.put( onSelect, field.get( instance ) );
|
||||
mapInstanceByField.put( field, instance );
|
||||
addListenerForField( componentBehaviour, field, instance );
|
||||
}
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
LeafObject leafObject = field.getAnnotation( LeafObject.class );
|
||||
if( leafObject != null )
|
||||
{
|
||||
String updateOn = leafObject.useWithAction();
|
||||
if( mapActionByName.containsKey( updateOn ) )
|
||||
{
|
||||
// valid action
|
||||
mapLeafObjectByActionName.put( updateOn, field );
|
||||
mapInstanceByField.put( field, instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch( IllegalAccessException exception )
|
||||
{
|
||||
exception.printStackTrace( System.out );
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFields()
|
||||
{
|
||||
Field[] allFields = this.getClass().getDeclaredFields();
|
||||
if( allFields != null )
|
||||
{
|
||||
loadFields( allFields, this );
|
||||
|
||||
}
|
||||
allFields = logicController.getClass().getDeclaredFields();
|
||||
if( allFields != null )
|
||||
{
|
||||
loadFields( allFields, logicController );
|
||||
|
||||
}
|
||||
for( JPanel panel : subPanels )
|
||||
{
|
||||
allFields = panel.getClass().getDeclaredFields();
|
||||
if( allFields != null )
|
||||
{
|
||||
loadFields( allFields, panel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadWindowMethods( Method[] windowMethods, Object instance )
|
||||
{
|
||||
for( Method method : windowMethods )
|
||||
{
|
||||
LeafUIActionBinding actionBinding = method.getAnnotation( LeafUIActionBinding.class );
|
||||
if( actionBinding != null )
|
||||
{
|
||||
String actionName = actionBinding.action();
|
||||
if( mapActionByName.containsKey( actionName ) )
|
||||
{
|
||||
// valid action
|
||||
mapAnnotationByObject.put( method, actionBinding );
|
||||
mapWindowMethodsByActionName.get( actionName ).add( method );
|
||||
mapInstanceByMethod.put( method, instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLogicMethods()
|
||||
{
|
||||
Method[] allLogicMethods = this.logicController.getClass().getDeclaredMethods();
|
||||
if( allLogicMethods != null )
|
||||
{
|
||||
for( Method method : allLogicMethods )
|
||||
{
|
||||
LeafLogicActionBinding actionBinding = method.getAnnotation( LeafLogicActionBinding.class );
|
||||
if( actionBinding != null )
|
||||
{
|
||||
String [] actions = actionBinding.actions();
|
||||
if( actions != null)
|
||||
{
|
||||
for(String actionName : actions)
|
||||
{
|
||||
if( mapActionByName.containsKey( actionName ) )
|
||||
{
|
||||
// valid action
|
||||
mapAnnotationByObject.put( method, actionBinding );
|
||||
mapLogicMethodByActionName.put( actionName, method );
|
||||
mapInstanceByMethod.put( method, logicController );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMethods()
|
||||
{
|
||||
loadLogicMethods();
|
||||
|
||||
Method[] allWindowMethods = this.getClass().getDeclaredMethods();
|
||||
if( allWindowMethods != null )
|
||||
{
|
||||
loadWindowMethods( allWindowMethods, this );
|
||||
}
|
||||
|
||||
for( JPanel panel : subPanels )
|
||||
{
|
||||
allWindowMethods = panel.getClass().getDeclaredMethods();
|
||||
if( allWindowMethods != null )
|
||||
{
|
||||
loadWindowMethods( allWindowMethods, panel );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Object getObjectForAction(String actionName)
|
||||
{
|
||||
Object result = null;
|
||||
Field field = mapLeafObjectByActionName.get( actionName );
|
||||
if( field != null )
|
||||
{
|
||||
Object instance = mapInstanceByField.get( field );
|
||||
if( instance != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
result = field.get( instance );
|
||||
} catch( IllegalArgumentException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
} catch( IllegalAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void runAction( String actionName )
|
||||
{
|
||||
runAction( actionName, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes given action
|
||||
*/
|
||||
public void runAction( String actionName, Object argument )
|
||||
{
|
||||
System.out.println("Running: "+actionName);
|
||||
if( actionName != null && mapActionByName.containsKey( actionName ) )
|
||||
{
|
||||
Action action = mapActionByName.get( actionName );
|
||||
if( action.isSave() )
|
||||
{
|
||||
Object windowArgument = getObjectForAction(actionName);
|
||||
Object logicArgument = windowArgument;
|
||||
for( Method currentWindowMethod : mapWindowMethodsByActionName.get( actionName ) )
|
||||
{
|
||||
Object currentLogicArgument = runWindowMethod( currentWindowMethod, windowArgument != null ? windowArgument : argument );
|
||||
logicArgument = logicArgument == null ? currentLogicArgument : logicArgument;
|
||||
}
|
||||
runLogicMethod( mapLogicMethodByActionName.get( actionName ), logicArgument );
|
||||
}
|
||||
else
|
||||
{
|
||||
Object windowArgument = runLogicMethod( mapLogicMethodByActionName.get( actionName ), argument );
|
||||
for( Method currentWindowMethod : mapWindowMethodsByActionName.get( actionName ) )
|
||||
{
|
||||
runWindowMethod( currentWindowMethod, windowArgument != null ? windowArgument : argument );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object runLogicMethod( Method logicMethod, Object argument )
|
||||
{
|
||||
Object result = null;
|
||||
try
|
||||
{
|
||||
if( logicMethod != null )
|
||||
{
|
||||
if( logicMethod.getParameterTypes().length > 0 )
|
||||
{
|
||||
result = logicMethod.invoke( logicController, argument );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = logicMethod.invoke( logicController );
|
||||
}
|
||||
}
|
||||
} catch( IllegalArgumentException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
} catch( IllegalAccessException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
} catch( InvocationTargetException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object runWindowMethod( Method windowMethod, Object argument )
|
||||
{
|
||||
Object result = null;
|
||||
try
|
||||
{
|
||||
if( windowMethod != null )
|
||||
{
|
||||
if( windowMethod.getParameterTypes().length > 0 )
|
||||
{
|
||||
result = windowMethod.invoke( mapInstanceByMethod.get( windowMethod ), argument );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = windowMethod.invoke( mapInstanceByMethod.get( windowMethod ) );
|
||||
}
|
||||
}
|
||||
} catch( IllegalArgumentException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
} catch( IllegalAccessException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
} catch( InvocationTargetException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open()
|
||||
{
|
||||
setVisible( true );
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
SwingUtilities.invokeLater( new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
setVisible( false );
|
||||
dispose();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeIfPossible()
|
||||
{
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh()
|
||||
{
|
||||
}
|
||||
|
||||
private void addListenerForField( ActionActivation annotation, Field field, Object instance )
|
||||
{
|
||||
if( instance instanceof JFrame || instance instanceof JPanel )
|
||||
{
|
||||
try
|
||||
{
|
||||
Object value = field.get( instance );
|
||||
if( value instanceof BaseTable )
|
||||
{
|
||||
((BaseTable) value).getSelectionModel().addListSelectionListener( this );
|
||||
}
|
||||
else if( value instanceof JTree )
|
||||
{
|
||||
((JTree) value).addTreeSelectionListener( this );
|
||||
}
|
||||
else if( value instanceof JButton )
|
||||
{
|
||||
((JButton) value).addActionListener( this );
|
||||
}
|
||||
} catch( IllegalAccessException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
} catch( NullPointerException e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object getArgumentListSelectionEvent( String actionName, ListSelectionEvent event )
|
||||
{
|
||||
Object source = event.getSource();
|
||||
Object result = null;
|
||||
Object component = mapWindowOnSelectFieldByActionName.get( actionName );
|
||||
if( component instanceof BaseTable && ((BaseTable) component).getSelectionModel().equals( source ) )
|
||||
{
|
||||
int index = ((BaseTable) component).getSelectedRow();
|
||||
if( index > -1 )
|
||||
{
|
||||
TableModel model = ((BaseTable) component).getModel();
|
||||
if( model instanceof VectorTableModel )
|
||||
{
|
||||
result = ((ColumnizedMappable) ((VectorTableModel) model).getRowAt( index )).getID();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getActionListSelectionEvent( ListSelectionEvent event )
|
||||
{
|
||||
for( String actionName : mapWindowOnSelectFieldByActionName.keySet() )
|
||||
{
|
||||
Object component = mapWindowOnSelectFieldByActionName.get( actionName );
|
||||
if( component != null && component instanceof BaseTable && event.getSource().equals( ((BaseTable) component).getSelectionModel() ) )
|
||||
{
|
||||
return actionName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// returns selected node
|
||||
private Object getArgumentTreeSelectionEvent( String actionName, TreeSelectionEvent event )
|
||||
{
|
||||
Object result = null;
|
||||
Object component = mapWindowOnSelectFieldByActionName.get( actionName );
|
||||
if( component instanceof JTree && event.getPath() != null )
|
||||
{
|
||||
Object[] nodes = event.getPath().getPath();
|
||||
if( nodes != null && nodes.length > 0 )
|
||||
{
|
||||
result = nodes[nodes.length - 1];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getActionTreeSelectionEvent( TreeSelectionEvent event )
|
||||
{
|
||||
for( String actionName : mapWindowOnSelectFieldByActionName.keySet() )
|
||||
{
|
||||
Object component = mapWindowOnSelectFieldByActionName.get( actionName );
|
||||
if( component != null && component instanceof JTree && event.getSource().equals( component ) )
|
||||
{
|
||||
return actionName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getActionActionEvent( ActionEvent event )
|
||||
{
|
||||
String result = null;
|
||||
for( String actionName : mapWindowOnSelectFieldByActionName.keySet() )
|
||||
{
|
||||
Object component = mapWindowOnSelectFieldByActionName.get( actionName );
|
||||
if( event.getSource().equals( component ) )
|
||||
{
|
||||
result = actionName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged( TreeSelectionEvent event )
|
||||
{
|
||||
String actionName = getActionTreeSelectionEvent( event );
|
||||
Object argument = getArgumentTreeSelectionEvent( actionName, event );
|
||||
runAction( actionName, argument );
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens to ListSelectionEvents
|
||||
*/
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
String actionName = getActionListSelectionEvent( event );
|
||||
Object argument = getArgumentListSelectionEvent( actionName, event );
|
||||
runAction( actionName, argument );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent event )
|
||||
{
|
||||
String actionName = getActionActionEvent( event );
|
||||
runAction( actionName, null );
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue