git-svn-id: https://svn.coded.pt/svn/SIPRP@606 bb69d46d-e84e-40c8-a05a-06db0d633741

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 18 years ago
parent ed03a2c2df
commit 78c0dab259

@ -1,5 +1,7 @@
package siprp.database.cayenne.objects;
import java.util.HashMap;
import siprp.database.cayenne.objects.auto._Trabalhadores;
public class Trabalhadores extends _Trabalhadores
@ -38,9 +40,12 @@ public class Trabalhadores extends _Trabalhadores
return getNomePlain() == null ? "" : getCapitalizedName();
}
public String getSexoString()
public HashMap<String, String> getSexos()
{
return getSexo() == null ? "" : ("f".equals( getSexo().toLowerCase() ) ? "Feminino" : "Masculino");
HashMap<String, String> result = new HashMap<String, String>();
result.put("f", "Feminino");
result.put( "m", "Masculino" );
return result;
}
@Override

@ -1,5 +1,7 @@
package siprp.database.cayenne.objects;
import java.util.Date;
import siprp.database.cayenne.objects.auto._TrabalhadoresConsultasDatas;
import siprp.medicina.MedicinaConstants;
@ -23,4 +25,24 @@ public class TrabalhadoresConsultasDatas extends _TrabalhadoresConsultasDatas im
{
return getDataString() + ": " + getEstadoString();
}
@Override
public void setData( Date date )
{
if( date != null && this.getToTrabalhadoresConsultas() != null && this.getEstado() != null && new Integer(ESTADO_POR_REALIZAR).equals(this.getEstado()))
{
this.getToTrabalhadoresConsultas().setData( date );
}
super.setData( date );
}
@Override
public void setEstado( Integer estado )
{
if( estado != null && this.getToTrabalhadoresConsultas() != null && (new Integer(ESTADO_POR_REALIZAR).equals( this.getEstado() ) || new Integer(ESTADO_POR_REALIZAR).equals( estado )))
{
this.getToTrabalhadoresConsultas().setEstado( estado );
}
super.setEstado( estado );
}
}

@ -1,6 +1,9 @@
package siprp.database.cayenne.objects;
import java.util.HashMap;
import siprp.database.cayenne.objects.auto._TrabalhadoresProcesso;
import siprp.medicina.MedicinaConstants;
import siprp.medicina.MedicinaDataProvider;
import siprp.medicina.processo.ProcessoConstants;
@ -38,6 +41,25 @@ public class TrabalhadoresProcesso extends _TrabalhadoresProcesso implements Pro
{
return getDataInicioString() + ": " + getMotivoString() + " : " + getDescricaoEstadoProcessoByCodigo();
}
public HashMap<String, String> getEstados()
{
HashMap<String,String> result = new HashMap<String, String>();
result.put( PROCESSO_ABERTO_CODE, PROCESSO_ABERTO_DESCRIPTION );
result.put( PROCESSO_CANCELADO_CODE, PROCESSO_CANCELADO_DESCRIPTION );
result.put( PROCESSO_FECHADO_CODE, PROCESSO_FECHADO_DESCRIPTION );
return result;
}
public HashMap<Integer, String> getMotivos()
{
HashMap<Integer,String> result = new HashMap<Integer, String>();
result.put( MedicinaConstants.MOTIVO_ADMISSAO_INTEGER, MedicinaConstants.MOTIVO_ADMISSAO_STR);
result.put( MedicinaConstants.MOTIVO_OCASIONAL_INTEGER, MedicinaConstants.MOTIVO_OCASIONAL_STR);
result.put( MedicinaConstants.MOTIVO_PERIODICO_INICIAL_INTEGER, MedicinaConstants.MOTIVO_PERIODICO_INICIAL_STR);
result.put( MedicinaConstants.MOTIVO_PERIODICO_INTEGER, MedicinaConstants.MOTIVO_PERIODICO_STR);
return result;
}
}

@ -12,6 +12,8 @@ import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.Trabalhadores;
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
import siprp.medicina.processo.ProcessoConstants;
import com.evolute.utils.tables.ColumnizedMappable;
@ -84,4 +86,10 @@ public class MedicinaDAO extends MainDAO
return object;
}
public void fecharProcesso( TrabalhadoresProcesso currentProcesso )
{
currentProcesso.setEstado( ProcessoConstants.PROCESSO_FECHADO_CODE );
context.commitChanges();
}
}

@ -39,7 +39,7 @@ public class SIPRPLogic
/**
* The name of the action this method binds to
*/
String action();
String [] action();
}
/**
@ -84,5 +84,13 @@ public class SIPRPLogic
window.runAction( actionName, argument );
}
}
public void runActionLater( String actionName )
{
for( SIPRPWindow window : registeredWindows )
{
window.runActionLater( actionName );
}
}
}

@ -19,6 +19,7 @@ import siprp.database.cayenne.objects.TrabalhadoresProcesso;
import siprp.database.cayenne.providers.MedicinaDAO;
import siprp.logic.SIPRPLogic;
import siprp.medicina.MedicinaConstants;
import siprp.medicina.processo.ProcessoConstants;
import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode;
import siprp.ui.SIPRPWindow.LeafObject;
@ -32,6 +33,9 @@ public class MedicinaProcessoLogic extends SIPRPLogic
@Action(isSave = false)
public static final String SELECT_ESTABELECIMENTO = "SELECT_ESTABLECIMENTO";
@Action(isSave = false)
public static final String LOAD_TRABALHADOR = "LOAD_TRABALHADOR";
@Action(isSave = false)
public static final String SELECT_TRABALHADOR = "SELECT_TRABALHADOR";
@ -68,92 +72,113 @@ public class MedicinaProcessoLogic extends SIPRPLogic
@Action(isSave = false)
public static final String SELECT_TREE_NODE = "SELECT_TREE_NODE";
@Action(isSave = false)
public static final String CREATE_PROCESSO = "CREATE_PROCESSO";
@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";
public static final String SAVE_PROCESSO = "SAVE_PROCESSO";
@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";
public static final String SAVE_FICHA = "SAVE_FICHA";
@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";
public static final String FECHAR_PROCESSO = "FECHAR_PROCESSO";
@Action(isSave = false)
public static final String REFRESH = "REFRESH";
@Action(isSave = false)
public static final String CLOSE = "CLOSE";
@Action(isSave = true)
public static final String DESMARCAR_CONSULTA_MARCACAO = "DESMARCAR_CONSULTA_MARCACAO";
@Action(isSave = true)
public static final String REALIZAR_CONSULTA_MARCACAO = "REALIZAR_CONSULTA_MARCACAO";
@Action(isSave = true)
public static final String FALTOU_CONSULTA_MARCACAO = "FALTOU_CONSULTA_MARCACAO";
private MedicinaDAO provider = null;
private Trabalhadores currentTrabalhador = null;
private TrabalhadoresProcesso currentProcesso = null;
@LeafObject(useWithAction = SAVE_PROCESSO)
public TrabalhadoresProcesso currentProcesso = null;
@LeafObject(useWithAction=SAVE_CONSULTA)
@LeafObject(useWithAction = SAVE_CONSULTA)
public TrabalhadoresConsultas currentConsulta = null;
@LeafObject(useWithAction=SAVE_CONSULTA_MARCACAO)
@LeafObject(useWithAction = SAVE_CONSULTA_MARCACAO)
public TrabalhadoresConsultasDatas currentConsultaMarcacao = null;
@LeafObject(useWithAction=SAVE_CONSULTA_MARCACAO_EMAIL)
@LeafObject(useWithAction = SAVE_CONSULTA_MARCACAO_EMAIL)
public TrabalhadoresConsultasDatasEmails currentConsultaMarcacaoEmail = null;
@LeafObject(useWithAction=SAVE_CONSULTA_MARCACAO_OBSERVACOES)
@LeafObject(useWithAction = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
public TrabalhadoresConsultasDatasObservacoes currentConsultaMarcacaoObservacao = null;
@LeafObject(useWithAction = SAVE_FICHA)
public FichaAptidaoMutableTreeNode currentFicha = null;
@LeafObject(useWithAction = SAVE_EXAME_MARCACAO_OBSERVACOES)
public TrabalhadoresEcdsDatasObservacoes currentExameMarcacaoObservacao = null;
@LeafObject(useWithAction = SAVE_EXAME_MARCACAO_EMAIL)
public TrabalhadoresEcdsDatasEmails currentExameMarcacaoEmail = null;
@LeafObject(useWithAction = SAVE_EXAME_MARCACAO)
public TrabalhadoresEcdsDatas currentExameMarcacao = null;
@LeafObject(useWithAction = SAVE_EXAME)
public TrabalhadoresEcds currentExame = null;
public MedicinaProcessoLogic()
@ -167,28 +192,37 @@ public class MedicinaProcessoLogic extends SIPRPLogic
}
}
@LeafLogicActionBinding(actions = { ACTION_STARTUP })
@LeafLogicActionBinding(actions = {
ACTION_STARTUP
})
public Vector<ColumnizedMappable> getAllEmpresas()
{
return provider.getAllEmpresas();
}
@LeafLogicActionBinding(actions = { SELECT_EMPRESA })
@LeafLogicActionBinding(actions = {
SELECT_EMPRESA
})
public Vector<ColumnizedMappable> getEstabelecimentosForEmpresa( Integer empresaID )
{
return provider.getEstabelecimentosForEmpresa( empresaID );
}
@LeafLogicActionBinding(actions = { SELECT_ESTABELECIMENTO })
@LeafLogicActionBinding(actions = {
SELECT_ESTABELECIMENTO
})
public Vector<ColumnizedMappable> getTrabalhadoresForEstabelecimento( Integer estabelecimentoID )
{
return provider.getTrabalhadoresForEstabelecimento( estabelecimentoID );
}
@LeafLogicActionBinding(actions = { SELECT_TRABALHADOR })
@LeafLogicActionBinding(actions = {
LOAD_TRABALHADOR
})
public Trabalhadores getDadosTrabalhador( Integer id )
{
Trabalhadores result = null;
clearAll();
if( id != null )
{
result = provider.getTrabalhadorByID( id );
@ -197,13 +231,63 @@ public class MedicinaProcessoLogic extends SIPRPLogic
return result;
}
@LeafLogicActionBinding(actions = { SELECT_TREE_NODE } )
@LeafLogicActionBinding(actions = FECHAR_PROCESSO)
public void fecharProcesso()
{
if( currentProcesso != null )
{
currentProcesso.setDataFim( new Date() );
currentProcesso.setEstado( ProcessoConstants.PROCESSO_FECHADO_CODE );
saveObject( currentProcesso );
}
}
@LeafLogicActionBinding(actions = DESMARCAR_CONSULTA_MARCACAO)
public void desmarcarConsulta()
{
if( currentConsultaMarcacao != null )
{
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_EMPRESA );
//TODO motivo
saveObject( currentConsultaMarcacao );
}
}
@LeafLogicActionBinding(actions = FALTOU_CONSULTA_MARCACAO)
public void faltouConsulta()
{
if( currentConsultaMarcacao != null )
{
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_FALTOU );
//TODO motivo
saveObject( currentConsultaMarcacao );
}
}
@LeafLogicActionBinding(actions = REALIZAR_CONSULTA_MARCACAO)
public void realizarConsulta()
{
if( currentConsultaMarcacao != null )
{
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_REALIZADO );
saveObject( currentConsultaMarcacao );
}
}
@LeafLogicActionBinding(actions = {
SELECT_TREE_NODE
})
public DefaultMutableTreeNode nodeSelected( DefaultMutableTreeNode node )
{
String action = null;
if( node.getUserObject() == null )
{
}
else if( node.getUserObject() instanceof Trabalhadores )
{
action = SELECT_TRABALHADOR;
currentTrabalhador = (Trabalhadores) node.getUserObject();
}
else if( node.getUserObject() instanceof TrabalhadoresProcesso )
{
action = SELECT_PROCESSO;
@ -258,7 +342,9 @@ public class MedicinaProcessoLogic extends SIPRPLogic
return node;
}
@LeafLogicActionBinding(actions = { CREATE_CONSULTA })
@LeafLogicActionBinding(actions = {
CREATE_CONSULTA
})
public TrabalhadoresConsultas createConsulta()
{
currentConsulta = new TrabalhadoresConsultas();
@ -267,48 +353,113 @@ public class MedicinaProcessoLogic extends SIPRPLogic
currentConsulta.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
return currentConsulta;
}
@LeafLogicActionBinding(actions = { CREATE_CONSULTA_MARCACAO })
@LeafLogicActionBinding(actions = {
CREATE_CONSULTA_MARCACAO
})
public TrabalhadoresConsultasDatas createConsultaMarcacao()
{
currentConsultaMarcacao = new TrabalhadoresConsultasDatas();
currentConsultaMarcacao.setToTrabalhadoresConsultas( currentConsulta );
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
runActionLater(SAVE_CONSULTA_MARCACAO);
return currentConsultaMarcacao;
}
@LeafLogicActionBinding(actions = { CREATE_CONSULTA_MARCACAO_EMAIL })
@LeafLogicActionBinding(actions = {
CREATE_CONSULTA_MARCACAO_EMAIL
})
public TrabalhadoresConsultasDatasEmails createConsultaMarcacaoEmails()
{
currentConsultaMarcacaoEmail = new TrabalhadoresConsultasDatasEmails();
currentConsultaMarcacaoEmail.setToTrabalhadoresConsultasDatas( currentConsultaMarcacao );
currentConsultaMarcacaoEmail.setSubject( " " );
currentConsultaMarcacaoEmail.setData( new Date(0) );
runActionLater(SAVE_CONSULTA_MARCACAO_EMAIL);
return currentConsultaMarcacaoEmail;
}
@LeafLogicActionBinding(actions = { CREATE_CONSULTA_MARCACAO_OBSERVACOES })
@LeafLogicActionBinding(actions = {
CREATE_CONSULTA_MARCACAO_OBSERVACOES
})
public TrabalhadoresConsultasDatasObservacoes createConsultaMarcacaoObservacoes()
{
currentConsultaMarcacaoObservacao = new TrabalhadoresConsultasDatasObservacoes();
currentConsultaMarcacaoObservacao.setToTrabalhadoresConsultasDatas( currentConsultaMarcacao );
runActionLater(SAVE_CONSULTA_MARCACAO_OBSERVACOES);
return currentConsultaMarcacaoObservacao;
}
@LeafLogicActionBinding(actions = { CREATE_EXAME })
@LeafLogicActionBinding(actions = CREATE_EXAME )
public TrabalhadoresEcds createExame()
{
currentExame = new TrabalhadoresEcds();
currentExame.setToTrabalhadores( currentTrabalhador );
currentExame.setToTrabalhadoresProcesso( currentProcesso );
currentExame.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
runActionLater(SAVE_EXAME);
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 })
@LeafLogicActionBinding(actions = CREATE_EXAME_MARCACAO )
public TrabalhadoresEcdsDatas createExameMarcacao()
{
currentExameMarcacao = new TrabalhadoresEcdsDatas();
currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
currentExameMarcacao.setToTrabalhadoresEcds( currentExame );
runActionLater(SAVE_EXAME_MARCACAO);
return currentExameMarcacao;
}
@LeafLogicActionBinding(actions = CREATE_EXAME_MARCACAO_OBSERVACOES )
public TrabalhadoresEcdsDatasObservacoes createExameMarcacaoObservacao()
{
currentExameMarcacaoObservacao = new TrabalhadoresEcdsDatasObservacoes();
currentExameMarcacaoObservacao.setToTrabalhadoresEcdsDatas( currentExameMarcacao );
runActionLater(SAVE_EXAME_MARCACAO_OBSERVACOES);
return currentExameMarcacaoObservacao;
}
@LeafLogicActionBinding(actions = CREATE_EXAME_MARCACAO_EMAIL )
public TrabalhadoresEcdsDatasEmails createExameMarcacaoEmail()
{
currentExameMarcacaoEmail = new TrabalhadoresEcdsDatasEmails();
currentExameMarcacaoEmail.setToTrabalhadoresEcdsDatas( currentExameMarcacao );
runActionLater(SAVE_EXAME_MARCACAO_EMAIL);
return currentExameMarcacaoEmail;
}
@LeafLogicActionBinding(actions = CREATE_PROCESSO )
public TrabalhadoresProcesso createProcesso()
{
currentProcesso = new TrabalhadoresProcesso();
currentProcesso.setDataInicio( new Date() );
currentProcesso.setEstado( ProcessoConstants.PROCESSO_ABERTO_CODE );
currentProcesso.setToTrabalhadores( currentTrabalhador );
runActionLater(SAVE_PROCESSO);
return currentProcesso;
}
@LeafLogicActionBinding(actions = {
SAVE_PROCESSO, 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 );
}
private void clearAll()
{
currentConsulta = null;
currentConsultaMarcacao = null;
currentConsultaMarcacaoEmail = null;
currentConsultaMarcacaoObservacao = null;
currentExame= null;
currentExameMarcacao = null;
currentExameMarcacaoEmail = null;
currentExameMarcacaoObservacao = null;
currentFicha = null;
currentProcesso = null;
currentTrabalhador = null;
}
}

@ -23,7 +23,7 @@ public class LeafButton extends JButton
boolean pushed = getModel().isPressed();
// Color borderColor = getBackground();
// Color highlightColor = getBackground();
Color textColor = getForeground();
Color textColor = isEnabled() ? getForeground() : getForeground().brighter().brighter().brighter();
Color textAccent = getBackground();
Color textAccentHot = getBackground();
GradientPaint topGradientUp = new GradientPaint( 0, 0, getBackground().brighter(), 0, getHeight() / 2, getBackground() );

@ -1,5 +1,8 @@
package siprp.medicina.processo.ui;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
@ -27,18 +30,49 @@ public class LeafCalendarDialog extends JDialog
private boolean ok = false;
private boolean clear = false;
Calendar cal = null;
private Calendar cal = null;
JComponent parent = null;
private JComponent parent = null;
private boolean enableClean = false;
private boolean enableCancel = false;
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();
super(parentFrame);
this.parent = parent;
this.enableClean = true;
setModal( true );
setupComponents();
setUndecorated( true );
setLocationRelativeTo( parent );
setVisible( true );
}
public LeafCalendarDialog(JFrame parentFrame, JComponent parent, boolean enableClean )
{
super(parentFrame);
this.parent = parent;
this.enableClean = enableClean;
setModal( true );
setupComponents();
setUndecorated( true );
setLocationRelativeTo( parent );
setVisible( true );
}
public LeafCalendarDialog(JFrame parentFrame, JComponent parent, boolean enableClean, boolean enableCancel )
{
super(parentFrame);
this.parent = parent;
this.enableClean = enableClean;
this.enableCancel = enableCancel;
setModal( true );
setupComponents();
setUndecorated( true );
@ -48,18 +82,11 @@ public class LeafCalendarDialog extends JDialog
private void setupComponents()
{
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
getContentPane().setLayout( gridbag );
TableLayout layout = new TableLayout(new double[]{TableLayout.FILL,TableLayout.FILL,TableLayout.FILL}, new double[]{TableLayout.FILL, TableLayout.MINIMUM});
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
constraints.gridheight = 1;
constraints.weighty = 1;
constraints.fill = GridBagConstraints.BOTH;
getContentPane().setLayout( layout );
gridbag.setConstraints( calendarPanel, constraints );
getContentPane().add( calendarPanel );
getContentPane().add( calendarPanel, new TableLayoutConstraints(0,0,2,0));
LeafButton okButton = new LeafButton( "OK" );
okButton.addActionListener( new ActionListener()
@ -71,6 +98,7 @@ public class LeafCalendarDialog extends JDialog
}
} );
LeafButton cancelarButton = new LeafButton( "Cancelar" );
cancelarButton.setEnabled( enableCancel );
cancelarButton.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
@ -79,7 +107,9 @@ public class LeafCalendarDialog extends JDialog
close();
}
} );
LeafButton limparButton = new LeafButton( "Limpar" );
limparButton.setEnabled(enableClean);
limparButton.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
@ -90,28 +120,10 @@ public class LeafCalendarDialog extends JDialog
}
} );
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 );
getContentPane().add( okButton, new TableLayoutConstraints(0,1) );
getContentPane().add( cancelarButton, new TableLayoutConstraints(1,1) );
getContentPane().add( limparButton, new TableLayoutConstraints(2,1) );
setSize( 250, 250 );

@ -15,7 +15,6 @@ 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
@ -24,7 +23,7 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
private static final DateFormat sdf = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
private static final int defaultColorDec = 10;
private static final int defaultColorDec = 20;
private int colorDec = defaultColorDec;
@ -42,9 +41,9 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
private ObjClass object = null;
private GradientPaint outerContour= null;
private GradientPaint outerReversedContour= null;
private GradientPaint innerContour= null;
private GradientPaint outerContour = null;
private GradientPaint outerReversedContour = null;
private GradientPaint innerContour = null;
private GradientPaint innerReversedContour = null;
private GradientPaint gradient = null;
@ -52,11 +51,13 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
{
super();
setOpaque( false );
super.setEditable( 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
@ -88,16 +89,14 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
@Override
public void mouseExited( MouseEvent e )
{
// colorDec = defaultColorDec;
background = cold;
background = isEditable ? cold : background;
repaint();
}
@Override
public void mouseEntered( MouseEvent e )
{
// colorDec = defaultColorDec + 10;
background = hot;
background = isEditable ? hot : background;
repaint();
}
@ -131,7 +130,19 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
} );
}
@Override
public void setText( String text )
{
try
{
setObject( (ObjClass) text );
} catch( ClassCastException ex )
{
ex.printStackTrace();
}
}
private String getStringFromUser()
{
LeafTextDialog textDialog = new LeafTextDialog( getParentFrame(), this, (String) object );
@ -179,7 +190,7 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
Graphics2D g2d = (Graphics2D) g;
int width = getWidth();
int height = getHeight();
setColors(width, height);
setColors( width, height );
g2d.setPaint( outerReversedContour );
g2d.fillRect( 15, 0, width / 4, height );
@ -193,19 +204,16 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
g2d.fillRoundRect( 0, 2, width, height - 5, 15, 15 );
super.paintComponent( g );
}
private void setColors(int width, int height)
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 );
}
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()
@ -227,11 +235,13 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
return getParent() != null ? getParent().getBackground() : startColor;
}
@Override
public void setEditable( boolean editable )
{
isEditable = editable;
}
@Override
public boolean isEditable()
{
return isEditable;
@ -245,7 +255,7 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
{
value = ((Map) object).get( selectedOption );
}
this.setText( value == null ? " " : value.toString() );
super.setText( value == null ? " " : value.toString() );
}
public Object getSelectedObject()
@ -260,7 +270,7 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
{
if( object instanceof Date )
{
this.setText( ((Date) object).getTime() <= 0 ? " " : sdf.format( object ) );
super.setText( ((Date) object).getTime() <= 0 ? " " : sdf.format( object ) );
}
else if( object instanceof Map )
{
@ -268,12 +278,12 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
}
else
{
this.setText( object.toString() );
super.setText( object.toString() );
}
}
else
{
this.setText( " " );
super.setText( " " );
}
}

@ -1,82 +0,0 @@
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 );
}
}

@ -4,6 +4,7 @@ import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
@ -17,17 +18,18 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
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 buttonSize = new Dimension( 30, 20 );
private static final Dimension textSize = new Dimension( 150, 15 );
private static final Dimension textSize = new Dimension( 200, 20 );
private static final Dimension expandedTextSize = new Dimension( 100, 200 );
private static final Dimension expandedTextSize = new Dimension( 300, 200 );
private String text = null;
@ -52,9 +54,9 @@ public class LeafTextDialog extends JDialog
setModal( true );
setContentPane( new LeafGradientPanel() );
textArea.setText( text );
expandButton.setSize( buttonSize );
cancelButton.setSize( buttonSize );
okButton.setSize( buttonSize );
expandButton.setPreferredSize( buttonSize );
cancelButton.setPreferredSize( buttonSize );
okButton.setPreferredSize( buttonSize );
setupLayout();
setUndecorated( true );
setLocationRelativeTo( parent );
@ -77,17 +79,29 @@ public class LeafTextDialog extends JDialog
TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED
};
rows = new double[] {
TableLayout.PREFERRED
TableLayout.PREFERRED, TableLayout.FILL
};
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 ) );
if(expand)
{
getContentPane().add( expandButton, new TableLayoutConstraints( 0, 0 ) );
getContentPane().add( new JPanel(), new TableLayoutConstraints( 0, 1 ) );
getContentPane().add( textArea, new TableLayoutConstraints( 1, 0,1,1 ) );
getContentPane().add( okButton, new TableLayoutConstraints( 2, 0 ) );
getContentPane().add( cancelButton, new TableLayoutConstraints( 3, 0 ) );
getContentPane().add( new JPanel(), new TableLayoutConstraints( 2, 1,3,1 ) );
}
else
{
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() );
@ -97,7 +111,7 @@ public class LeafTextDialog extends JDialog
private void setupComponents(boolean expand)
{
getContentPane().setLayout( expand ? expandedLayout : layout);
textArea.setSize( expand ? expandedTextSize : textSize );
textArea.setPreferredSize( expand ? expandedTextSize : textSize );
expandButton.setText( expand ? "-" : "+" );
placeComponents(expand);
}

@ -8,8 +8,6 @@ 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;
@ -19,11 +17,12 @@ import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_M
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 static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.CardLayout;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
@ -40,6 +39,8 @@ 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.medicina.MedicinaConstants;
import siprp.medicina.processo.ProcessoConstants;
import siprp.ui.SIPRPWindow;
import siprp.ui.SIPRPWindow.ActionActivation;
@ -81,11 +82,15 @@ public class ProcessoAccoesPanel extends JPanel
private final JPanel panelStart = new JPanel();
// trabalhador
@ActionActivation(onSelect = CREATE_PROCESSO, onChange = "")
public final LeafButton buttonNovoTrabalhadorProcesso = new LeafButton( "Novo Processo" );
// processo
@ActionActivation(onSelect = FECHAR_PROCESSO, onChange = "")
public final LeafButton buttonFecharProcesso = new LeafButton( "Fechar Processo" );
@ActionActivation(onSelect = CREATE_CONSULTA, onChange = "")
@ActionActivation(onSelect = {
CREATE_CONSULTA, CREATE_CONSULTA_MARCACAO
}, onChange = "")
public final LeafButton buttonNovoProcessoConsulta = new LeafButton( "Nova Consulta" );
@ActionActivation(onSelect = CREATE_EXAME, onChange = "")
public final LeafButton buttonNovoProcessoExame = new LeafButton( "Novo Exame" );
@ -100,6 +105,15 @@ public class ProcessoAccoesPanel extends JPanel
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_OBSERVACOES, onChange = "")
public final LeafButton buttonNovoConsultaMarcacaoObservacoes = new LeafButton( "Adicionar Observa" + ccedil + atilde + "o" );
@ActionActivation(onSelect = DESMARCAR_CONSULTA_MARCACAO, onChange = "")
public final LeafButton buttonConsultaMarcacaoDesmarcar = new LeafButton( "Desmarcar" );
@ActionActivation(onSelect = REALIZAR_CONSULTA_MARCACAO, onChange = "")
public final LeafButton buttonConsultaMarcacaoRealizar = new LeafButton( "Realizar" );
@ActionActivation(onSelect = FALTOU_CONSULTA_MARCACAO, onChange = "")
public final LeafButton buttonConsultaMarcacaoFaltou = new LeafButton( "Faltou" );
// email marcacao consulta
// observacoes marcacao consulta
@ -114,16 +128,10 @@ public class ProcessoAccoesPanel extends JPanel
// 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)
{
@ -141,11 +149,11 @@ public class ProcessoAccoesPanel extends JPanel
TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM
} );
this.setLayout( layout );
cardPanel.setLayout( cardLayout );
layout = new TableLayout( new double[] {
TableLayout.FILL, TableLayout.FILL
TableLayout.FILL, TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM
} );
@ -175,21 +183,35 @@ public class ProcessoAccoesPanel extends JPanel
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) );
// 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)
@LeafUIActionBinding(action = {
LOAD_TRABALHADOR, SELECT_TRABALHADOR
})
public void setForTrabalhador( Trabalhadores trabalhador )
{
if( trabalhador != null )
{
boolean processoAberto = false;
for( TrabalhadoresProcesso processo : (List<TrabalhadoresProcesso>) trabalhador.getTrabalhadoresProcessoArray() )
{
if( ProcessoConstants.PROCESSO_ABERTO_CODE.equals( processo.getEstado() ) )
{
processoAberto = true;
break;
}
}
buttonNovoTrabalhadorProcesso.setEnabled( !processoAberto );
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
}
else
@ -203,6 +225,18 @@ public class ProcessoAccoesPanel extends JPanel
{
if( processo != null )
{
buttonFecharProcesso.setEnabled( !ProcessoConstants.PROCESSO_FECHADO_CODE.equals( processo.getEstado() ) );
boolean consultaAberta = false;
for( TrabalhadoresConsultas consulta : (List<TrabalhadoresConsultas>) processo.getTrabalhadoresConsultasArray() )
{
if( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( consulta.getEstado() ) )
{
consultaAberta = true;
break;
}
}
buttonNovoProcessoConsulta.setEnabled( !consultaAberta );
cardLayout.show( cardPanel, PANEL_PROCESSO_NAME );
}
else
@ -216,8 +250,17 @@ public class ProcessoAccoesPanel extends JPanel
{
if( consulta != null )
{
boolean marcacaoAberta = false;
for( TrabalhadoresConsultasDatas marcacao : (List<TrabalhadoresConsultasDatas>) consulta.getTrabalhadoresConsultasDatasArray() )
{
if( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() ) )
{
marcacaoAberta = true;
break;
}
}
buttonNovoConsultaMarcacao.setEnabled( !marcacaoAberta && !new Integer(MedicinaConstants.ESTADO_REALIZADO).equals( consulta.getEstado() ));
cardLayout.show( cardPanel, PANEL_CONSULTA_NAME );
nextSaveAction = SAVE_CONSULTA;
}
else
{
@ -230,8 +273,12 @@ public class ProcessoAccoesPanel extends JPanel
{
if( marcacao != null )
{
boolean porRealizar = new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() );
buttonConsultaMarcacaoDesmarcar.setEnabled( porRealizar );
buttonConsultaMarcacaoFaltou.setEnabled( porRealizar );
buttonConsultaMarcacaoRealizar.setEnabled( porRealizar );
// buttonNovoConsultaMarcacaoObservacoes.setEnabled( );
cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME );
nextSaveAction = SAVE_CONSULTA_MARCACAO;
}
else
{
@ -244,8 +291,7 @@ public class ProcessoAccoesPanel extends JPanel
{
if( email != null )
{
cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME );
nextSaveAction = SAVE_CONSULTA_MARCACAO_EMAIL;
cardLayout.show( cardPanel, PANEL_START_NAME );
}
else
{
@ -258,8 +304,7 @@ public class ProcessoAccoesPanel extends JPanel
{
if( obs != null )
{
cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME );
nextSaveAction = SAVE_CONSULTA_MARCACAO_OBSERVACOES;
cardLayout.show( cardPanel, PANEL_START_NAME );
}
else
{
@ -298,7 +343,7 @@ public class ProcessoAccoesPanel extends JPanel
{
if( email != null )
{
cardLayout.show( cardPanel, SELECT_EXAME_MARCACAO );
cardLayout.show( cardPanel, PANEL_START_NAME );
}
else
{
@ -311,30 +356,18 @@ public class ProcessoAccoesPanel extends JPanel
{
if( obs != null )
{
cardLayout.show( cardPanel, SELECT_EXAME_MARCACAO );
cardLayout.show( cardPanel, PANEL_START_NAME );
}
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" ) );
// panelStart.setBorder( BorderFactory.createTitledBorder(
// BorderFactory.createEtchedBorder(), "none" ) );
}
private void setupTrabalhadorPanel()
@ -354,7 +387,7 @@ public class ProcessoAccoesPanel extends JPanel
private void setupConsultaMarcacaoPanel()
{
setupSimpleActionsPanel( panelConsultaMarcacao, buttonNovoConsultaMarcacaoEmail, buttonNovoConsultaMarcacaoObservacoes, new JPanel() );
setupSimpleActionsPanel( panelConsultaMarcacao, buttonNovoConsultaMarcacaoEmail, buttonNovoConsultaMarcacaoObservacoes, buttonConsultaMarcacaoRealizar, buttonConsultaMarcacaoDesmarcar, buttonConsultaMarcacaoFaltou, new JPanel() );
}
private void setupExamePanel()

@ -21,7 +21,7 @@ import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_M
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 static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
@ -31,6 +31,7 @@ import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
@ -94,11 +95,11 @@ public class ProcessoDadosPanel extends JPanel
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( "" );
private final LeafInputField<String> inputTrabalhadorNome = new LeafInputField<String>();
private final LeafInputField<HashMap<String,String>> inputTrabalhadorSexo = new LeafInputField<HashMap<String,String>>();
private final LeafInputField<Date> inputTrabalhadorDataNascimento = new LeafInputField<Date>();
private final LeafInputField<String> inputTrabalhadorNacionalidade = new LeafInputField<String>();
private final LeafInputField<String> inputTrabalhadorObservacoes = new LeafInputField<String>();
// processo
@ -107,62 +108,62 @@ public class ProcessoDadosPanel extends JPanel
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>( );
private final LeafInputField<HashMap<String,String>> inputProcessoEstado = new LeafInputField<HashMap<String,String>>();
private final LeafInputField<Date> inputProcessoDataInicio = new LeafInputField<Date>();
private final LeafInputField<Date> inputProcessoDataFim = new LeafInputField<Date>();
private final LeafInputField<HashMap<Integer,String>> inputProcessoMotivo = new LeafInputField<HashMap<Integer,String>>();
// 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>( );
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>( );
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( "" );
private final LeafInputField<Date> inputConsultaMarcacaoEmailData = new LeafInputField<Date>();
private final LeafInputField<String> inputConsultaMarcacaoEmailSubject = new LeafInputField<String>();
private final LeafInputField<String> inputConsultaMarcacaoEmailBody = new LeafInputField<String>();
// observacao marcacao consulta
private final LeafTextArea inputConsultaMarcacaoObsMensagem = new LeafTextArea( "" );
private final LeafInputField<String> inputConsultaMarcacaoObsMensagem = new LeafInputField<String>();
// 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>( );
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>( );
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( "" );
private final LeafInputField<Date> inputExameMarcacaoEmailData = new LeafInputField<Date>();
private final LeafInputField<String> inputExameMarcacaoEmailSubject = new LeafInputField<String>();
private final LeafInputField<String> inputExameMarcacaoEmailBody = new LeafInputField<String>();
// observacao marcacao exame
private final LeafTextArea inputExameMarcacaoObsMensagem = new LeafTextArea( "" );
private final LeafInputField<String> inputExameMarcacaoObsMensagem = new LeafInputField<String>();
public ProcessoDadosPanel(SIPRPWindow parentWindow)
{
@ -207,17 +208,18 @@ public class ProcessoDadosPanel extends JPanel
add( panelExameMarcacaoObservacao, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
}
@LeafUIActionBinding(action = SELECT_TRABALHADOR)
@LeafUIActionBinding(action = { LOAD_TRABALHADOR, SELECT_TRABALHADOR })
public void setForTrabalhador( Trabalhadores trabalhador )
{
if( trabalhador != null )
{
inputTrabalhadorDataNascimento.setObject( trabalhador.getDataNascimento() );
inputTrabalhadorSexo.setObject( trabalhador.getSexo() );
inputTrabalhadorSexo.setObject( trabalhador.getSexos() );
inputTrabalhadorSexo.setSelectedObject( trabalhador.getSexo() );
inputTrabalhadorNome.setObject( trabalhador.getNome() );
inputTrabalhadorNacionalidade.setObject( trabalhador.getNacionalidade() );
inputTrabalhadorObservacoes.setText( trabalhador.getObservacoes() );
inputTrabalhadorObservacoes.setObject( trabalhador.getObservacoes() );
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
}
else
@ -230,12 +232,14 @@ public class ProcessoDadosPanel extends JPanel
public void setForProcesso( TrabalhadoresProcesso processo )
{
if( processo != null )
{
inputProcessoDataFim.setObject( processo.getDataFim());
{
inputProcessoDataFim.setObject( processo.getDataFim() );
inputProcessoDataInicio.setObject( processo.getDataInicio() );
inputProcessoEstado.setObject( processo.getEstado() );
inputProcessoMotivo.setObject( processo.getMotivo() );
inputProcessoEstado.setObject( processo.getEstados() );
inputProcessoEstado.setSelectedObject( processo.getEstado() );
inputProcessoMotivo.setObject( processo.getMotivos() );
inputProcessoMotivo.setSelectedObject( processo.getMotivo() );
cardLayout.show( this, PANEL_PROCESSO_NAME );
}
else
@ -251,10 +255,11 @@ public class ProcessoDadosPanel extends JPanel
{
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) ) );
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
@ -284,8 +289,8 @@ public class ProcessoDadosPanel extends JPanel
{
if( email != null )
{
inputConsultaMarcacaoEmailBody.setText( email.getBody() );
inputConsultaMarcacaoEmailSubject.setText( email.getSubject() );
inputConsultaMarcacaoEmailBody.setObject( email.getBody() );
inputConsultaMarcacaoEmailSubject.setObject( email.getSubject() );
inputConsultaMarcacaoEmailData.setObject( email.getData() );
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_EMAIL_NAME );
}
@ -300,7 +305,8 @@ public class ProcessoDadosPanel extends JPanel
{
if( obs != null )
{
inputConsultaMarcacaoObsMensagem.setText( obs.getObservacao() );
inputConsultaMarcacaoObsMensagem.setEditable( true );
inputConsultaMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() );
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME );
}
else
@ -314,8 +320,8 @@ public class ProcessoDadosPanel extends JPanel
{
if( exame != null )
{
inputExameData.setText( exame.getDataString() );
inputExameEstado.setText( exame.getEstadoString() );
inputExameData.setObject( exame.getData() );
inputExameEstado.setObject( exame.getEstadoString() );
cardLayout.show( this, PANEL_EXAME_NAME );
}
else
@ -329,8 +335,8 @@ public class ProcessoDadosPanel extends JPanel
{
if( exameMarcacao != null )
{
inputExameMarcacaoData.setText( exameMarcacao.getDataString() );
inputExameMarcacaoEstado.setText( exameMarcacao.getEstadoString() );
inputExameMarcacaoData.setObject( exameMarcacao.getData() );
inputExameMarcacaoEstado.setObject( exameMarcacao.getEstadoString() );
cardLayout.show( this, PANEL_EXAME_MARCACAO_NAME );
}
else
@ -344,9 +350,9 @@ public class ProcessoDadosPanel extends JPanel
{
if( email != null )
{
inputExameMarcacaoEmailBody.setText( email.getBody() );
inputExameMarcacaoEmailSubject.setText( email.getSubject() );
inputExameMarcacaoEmailData.setText( email.getDataString() );
inputExameMarcacaoEmailBody.setObject( email.getBody() );
inputExameMarcacaoEmailSubject.setObject( email.getSubject() );
inputExameMarcacaoEmailData.setObject( email.getData() );
cardLayout.show( this, PANEL_EXAME_MARCACAO_EMAIL_NAME );
}
else
@ -360,7 +366,7 @@ public class ProcessoDadosPanel extends JPanel
{
if( obs != null )
{
inputExameMarcacaoObsMensagem.setText( obs.getObservacao() );
inputExameMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() );
cardLayout.show( this, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
}
else
@ -373,16 +379,16 @@ public class ProcessoDadosPanel extends JPanel
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 );
LeafCalendarDialog calendar = new LeafCalendarDialog( getParentFrame(), this, false );
Date date = calendar.getDate();
marcacao.setData( date );
}
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL)
public void setForNewConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
{
@ -390,27 +396,27 @@ public class ProcessoDadosPanel extends JPanel
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 )
{
@ -418,7 +424,7 @@ public class ProcessoDadosPanel extends JPanel
email.setData( inputConsultaMarcacaoEmailData.getObject() );
email.setSubject( inputConsultaMarcacaoEmailSubject.getText() );
}
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
public void updateToSaveConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes )
{
@ -518,4 +524,13 @@ public class ProcessoDadosPanel extends JPanel
inputExameMarcacaoObsMensagem.setEditable( false );
setupSimpleDataPanel( panelExameMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputExameMarcacaoObsMensagem );
}
private JFrame getParentFrame()
{
if( getRootPane() != null && getRootPane().getParent() instanceof JFrame )
{
return (JFrame) getRootPane().getParent();
}
return null;
}
}

@ -2,7 +2,7 @@ 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.LOAD_TRABALHADOR;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TREE_NODE;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
@ -32,6 +32,7 @@ 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.LeafLogicActionBinding;
import siprp.logic.SIPRPLogic.LeafUIActionBinding;
import siprp.medicina.MarcacaoConsultaExtendedPanel;
import siprp.medicina.processo.ProcessoDataProvider;
@ -110,7 +111,7 @@ public class ProcessoTreePanel extends JPanel
this.add( mainScroll, new TableLayoutConstraints( 0, 0 ) );
}
@LeafUIActionBinding(action = SELECT_TRABALHADOR)
@LeafUIActionBinding(action = LOAD_TRABALHADOR)
public void setTrabalhador( Trabalhadores trabalhador )
{
clear();
@ -131,6 +132,16 @@ public class ProcessoTreePanel extends JPanel
mainTree.expandRow( n );
}
}
@LeafUIActionBinding(action = CREATE_PROCESSO)
public void createConsultaNode( TrabalhadoresProcesso processo)
{
if( processo!= null )
{
ProcessoMutableTreeNode node = new ProcessoMutableTreeNode( processo );
addAndRefresh( node, rootNode );
}
}
@LeafUIActionBinding(action = CREATE_CONSULTA)
public void createConsultaNode( TrabalhadoresConsultas consulta )
@ -147,13 +158,15 @@ public class ProcessoTreePanel extends JPanel
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO)
public void createConsultaMarcacaoNode( TrabalhadoresConsultasDatas marcacao )
{
if( marcacao != null )
if( marcacao != null)
{
DefaultMutableTreeNode parentNode = nodeByObject.get( marcacao.getToTrabalhadoresConsultas() );
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
addAndRefresh( node, parentNode );
addAndRefresh( node, parentNode );
}
}
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL)
public void createConsultaMarcacaoEmailNode( TrabalhadoresConsultasDatasEmails email )
@ -192,7 +205,19 @@ public class ProcessoTreePanel extends JPanel
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() ) );
}
}
protected List<DefaultMutableTreeNode> loadProcessos( Trabalhadores trabalhador )
{
List<DefaultMutableTreeNode> result = new ArrayList<DefaultMutableTreeNode>();
@ -286,19 +311,23 @@ public class ProcessoTreePanel extends JPanel
private void addAndRefresh( DefaultMutableTreeNode node, DefaultMutableTreeNode parentNode )
{
addNodeTo( node, parentNode );
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
mainTree.setSelectionPath( new TreePath( node.getPath() ) );
refresh(node, parentNode);
}
@LeafUIActionBinding(action = REFRESH)
public void refresh()
// private void removeNode( DefaultMutableTreeNode node )
// {
// if( node != null && !node.equals( rootNode ) && node.getParent() != null && node.getParent() instanceof DefaultMutableTreeNode)
// {
// DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
// node.removeFromParent();
// refresh(parent, rootNode);
// }
// }
private void refresh(DefaultMutableTreeNode newSelection, DefaultMutableTreeNode parentNode)
{
DefaultMutableTreeNode selected = getSelectedNode();
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
if( selected != null )
{
mainTree.setSelectionPath( new TreePath( selected.getPath() ) );
}
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
mainTree.setSelectionPath( new TreePath( newSelection.getPath() ) );
}
private DefaultMutableTreeNode getSelectedNode()
@ -314,11 +343,10 @@ public class ProcessoTreePanel extends JPanel
public void clear()
{
rootNode.setUserObject( "" );
mainTree.clearSelection();
mainTree.setRootVisible( true );
rootNode.removeAllChildren();
// PROCESSOS_POR_ID.clear();
rootNode.setUserObject( "" );
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
}
}

@ -3,7 +3,7 @@ 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 static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@ -36,7 +36,7 @@ public class TrabalhadoresChooserPanel extends JPanel
public BaseTable estabelecimentosTable;
public VectorTableModel estabelecimentosModel;
@ActionActivation(onSelect = SELECT_TRABALHADOR, onChange = "")
@ActionActivation(onSelect = LOAD_TRABALHADOR, onChange = "")
public BaseTable trabalhadoresTable;
public VectorTableModel trabalhadoresModel;

@ -12,9 +12,12 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import javax.swing.DefaultListSelectionModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
@ -56,7 +59,7 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
*
* @return
*/
String onSelect();
String [] onSelect();
/**
* Array of actions to execute when a change is listened in this
@ -64,7 +67,7 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
*
* @return
*/
String onChange();
String [] onChange();
}
@ -110,8 +113,8 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
/**
* Fields
*/
private Map<String, Object> mapWindowOnSelectFieldByActionName = new HashMap<String, Object>();
private Map<String, Object> mapWindowOnChangeFieldByActionName = new HashMap<String, Object>();
private Map<String, List<Object>> mapWindowOnSelectFieldByActionName = new HashMap<String, List<Object>>();
private Map<String, List<Object>> mapWindowOnChangeFieldByActionName = new HashMap<String, List<Object>>();
private Map<String, Field> mapLeafObjectByActionName = new HashMap<String, Field>();
private Map<Field, Object> mapInstanceByField = new HashMap<Field, Object>();
@ -126,6 +129,11 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
* Meta-info
*/
private Map<Object, Annotation> mapAnnotationByObject = new HashMap<Object, Annotation>();
/**
* Run later actions
*/
private Queue<String> listRunLater = new LinkedList<String>();
public SIPRPWindow(SIPRPLogic logicController) throws IllegalArgumentException, IllegalAccessException
{
@ -180,6 +188,8 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
{
mapActionByName.put( value, action );
mapWindowMethodsByActionName.put( value, new ArrayList<Method>() );
mapWindowOnSelectFieldByActionName.put( value, new ArrayList<Object>() );
mapWindowOnChangeFieldByActionName.put( value, new ArrayList<Object>() );
}
}
}
@ -194,36 +204,43 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
ActionActivation componentBehaviour = field.getAnnotation( ActionActivation.class );
if( componentBehaviour != null )
{
String onChange = componentBehaviour.onChange();
// if( onChange != null )
// {
// for( String currentOnChange : onChange )
// {
if( mapActionByName.containsKey( onChange ) )
String[] allChanges = componentBehaviour.onChange();
if( allChanges != null )
{
// valid action
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
mapWindowOnChangeFieldByActionName.put( onChange, field.get( instance ) );
mapInstanceByField.put( field, instance );
addListenerForField( componentBehaviour, field, instance );
for( String onChange : allChanges )
{
if( mapActionByName.containsKey( onChange ) )
{
// valid action
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
mapWindowOnChangeFieldByActionName.get( onChange ).add( field.get( instance ) );
if(!mapInstanceByField.containsKey( field ))
{
addListenerForField( componentBehaviour, field, instance );
mapInstanceByField.put( field, instance );
}
}
}
}
// }
// }
String onSelect = componentBehaviour.onSelect();
// if( onSelect != null )
// {
// for( String currentOnSelect : onSelect )
// {
if( mapActionByName.containsKey( onSelect ) )
String[] allSelect = componentBehaviour.onSelect();
if( allSelect != null )
{
// valid action
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
mapWindowOnSelectFieldByActionName.put( onSelect, field.get( instance ) );
mapInstanceByField.put( field, instance );
addListenerForField( componentBehaviour, field, instance );
for( String onSelect : allSelect )
{
if( mapActionByName.containsKey( onSelect ) )
{
// valid action
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
mapWindowOnSelectFieldByActionName.get( onSelect ).add( field.get( instance ) );
if(!mapInstanceByField.containsKey( field ))
{
addListenerForField( componentBehaviour, field, instance );
mapInstanceByField.put( field, instance );
}
}
}
}
// }
// }
}
LeafObject leafObject = field.getAnnotation( LeafObject.class );
@ -275,13 +292,17 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
LeafUIActionBinding actionBinding = method.getAnnotation( LeafUIActionBinding.class );
if( actionBinding != null )
{
String actionName = actionBinding.action();
if( mapActionByName.containsKey( actionName ) )
String [] actions = actionBinding.action();
for(String actionName : actions)
{
// valid action
mapAnnotationByObject.put( method, actionBinding );
mapWindowMethodsByActionName.get( actionName ).add( method );
mapInstanceByMethod.put( method, instance );
if( mapActionByName.containsKey( actionName ) )
{
// valid action
mapWindowMethodsByActionName.get( actionName ).add( method );
mapAnnotationByObject.put( method, actionBinding );
mapInstanceByMethod.put( method, instance );
}
}
}
}
@ -297,10 +318,10 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
LeafLogicActionBinding actionBinding = method.getAnnotation( LeafLogicActionBinding.class );
if( actionBinding != null )
{
String [] actions = actionBinding.actions();
if( actions != null)
String[] actions = actionBinding.actions();
if( actions != null )
{
for(String actionName : actions)
for( String actionName : actions )
{
if( mapActionByName.containsKey( actionName ) )
{
@ -336,8 +357,8 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
}
}
private Object getObjectForAction(String actionName)
private Object getObjectForAction( String actionName )
{
Object result = null;
Field field = mapLeafObjectByActionName.get( actionName );
@ -358,26 +379,49 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
}
}
}
return result;
return result;
}
public void runAction( String actionName )
{
runAction( actionName, null );
runGivenAction( actionName, null );
runPendingActions();
}
public void runAction( String actionName, Object argument)
{
runGivenAction( actionName, argument );
runPendingActions();
}
public void runActionLater(String action)
{
if( action != null && mapActionByName.containsKey( action ))
{
listRunLater.add( action );
}
}
private void runPendingActions()
{
while( listRunLater.size() > 0)
{
runAction( listRunLater.poll() );
}
}
/**
* Executes given action
*/
public void runAction( String actionName, Object argument )
private void runGivenAction( String actionName, Object argument )
{
System.out.println("Running: "+actionName);
System.out.println( "Running: " + actionName );
if( actionName != null && mapActionByName.containsKey( actionName ) )
{
Action action = mapActionByName.get( actionName );
if( action.isSave() )
{
Object windowArgument = getObjectForAction(actionName);
Object windowArgument = getObjectForAction( actionName );
Object logicArgument = windowArgument;
for( Method currentWindowMethod : mapWindowMethodsByActionName.get( actionName ) )
{
@ -517,75 +561,106 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
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 ) )
List<Object> allComponents = mapWindowOnSelectFieldByActionName.get( actionName );
for( Object component : allComponents )
{
int index = ((BaseTable) component).getSelectedRow();
if( index > -1 )
if( component instanceof BaseTable && ((BaseTable) component).getSelectionModel().equals( source ) )
{
TableModel model = ((BaseTable) component).getModel();
if( model instanceof VectorTableModel )
int index = ((BaseTable) component).getSelectedRow();
if( index > -1 )
{
result = ((ColumnizedMappable) ((VectorTableModel) model).getRowAt( index )).getID();
TableModel model = ((BaseTable) component).getModel();
if( model instanceof VectorTableModel )
{
return ((ColumnizedMappable) ((VectorTableModel) model).getRowAt( index )).getID();
}
}
}
}
return result;
return null;
}
private String getActionListSelectionEvent( ListSelectionEvent event )
private List<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() ) )
List<String> result = new ArrayList<String>();
if( event.getSource() instanceof DefaultListSelectionModel)
{
DefaultListSelectionModel model = (DefaultListSelectionModel) event.getSource();
BaseTable table = null;
for(List<Object> allComponents : mapWindowOnSelectFieldByActionName.values()){
// for each registered table
for( Object component : allComponents )
{
if( component instanceof BaseTable && ((BaseTable) component).getSelectionModel().equals( model ) )
{
table = (BaseTable) component;
}
if( table != null)
{
break;
}
}
if( table != null)
{
break;
}
}
Annotation an = mapAnnotationByObject.get( table );
if(an != null && an instanceof ActionActivation)
{
return actionName;
String [] actions = ((ActionActivation) an).onSelect();
for( String actionName : actions )
{
result.add( actionName );
}
}
}
return null;
return result;
}
// 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 )
List<Object> components = mapWindowOnSelectFieldByActionName.get( actionName );
for( Object component : components )
{
Object[] nodes = event.getPath().getPath();
if( nodes != null && nodes.length > 0 )
if( component instanceof JTree && event.getPath() != null )
{
result = nodes[nodes.length - 1];
Object[] nodes = event.getPath().getPath();
if( nodes != null && nodes.length > 0 )
{
return nodes[nodes.length - 1];
}
}
}
return result;
return null;
}
private String getActionTreeSelectionEvent( TreeSelectionEvent event )
private List<String> getActionTreeSelectionEvent( TreeSelectionEvent event )
{
for( String actionName : mapWindowOnSelectFieldByActionName.keySet() )
List<String> result = new ArrayList<String>();
Annotation an = mapAnnotationByObject.get( event.getSource() );
if(an != null && an instanceof ActionActivation)
{
Object component = mapWindowOnSelectFieldByActionName.get( actionName );
if( component != null && component instanceof JTree && event.getSource().equals( component ) )
String [] actions = ((ActionActivation) an).onSelect();
for( String actionName : actions )
{
return actionName;
result.add( actionName );
}
}
return null;
return result;
}
private String getActionActionEvent( ActionEvent event )
private List<String> getActionActionEvent( ActionEvent event )
{
String result = null;
for( String actionName : mapWindowOnSelectFieldByActionName.keySet() )
List<String> result = new ArrayList<String>();
Annotation an = mapAnnotationByObject.get( event.getSource() );
if(an != null && an instanceof ActionActivation)
{
Object component = mapWindowOnSelectFieldByActionName.get( actionName );
if( event.getSource().equals( component ) )
String [] actions = ((ActionActivation) an).onSelect();
for( String actionName : actions )
{
result = actionName;
break;
result.add( actionName );
}
}
return result;
@ -594,9 +669,12 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
@Override
public void valueChanged( TreeSelectionEvent event )
{
String actionName = getActionTreeSelectionEvent( event );
Object argument = getArgumentTreeSelectionEvent( actionName, event );
runAction( actionName, argument );
List<String> actions= getActionTreeSelectionEvent( event );
for( String action : actions )
{
Object argument = getArgumentTreeSelectionEvent( action, event );
runAction( action, argument );
}
}
/**
@ -607,16 +685,22 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio
{
if( !event.getValueIsAdjusting() )
{
String actionName = getActionListSelectionEvent( event );
Object argument = getArgumentListSelectionEvent( actionName, event );
runAction( actionName, argument );
List<String> actionNames = getActionListSelectionEvent( event );
for( String action : actionNames )
{
Object argument = getArgumentListSelectionEvent(action, event);
runAction( action, argument );
}
}
}
@Override
public void actionPerformed( ActionEvent event )
{
String actionName = getActionActionEvent( event );
runAction( actionName, null );
List<String> actionName = getActionActionEvent( event );
for( String action : actionName )
{
runAction( action, null );
}
}
}

Loading…
Cancel
Save