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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 18 years ago
parent 23d67d0061
commit d6b09410fc

@ -155,7 +155,7 @@ public class LeafInputField<ObjClass extends Object> extends JTextArea
private Object getOptionFromUser() private Object getOptionFromUser()
{ {
LeafOptionDialog optionDialog = new LeafOptionDialog( getParentFrame(), this, (Map) object ); LeafOptionDialog<Object> optionDialog = new LeafOptionDialog<Object>( getParentFrame(), this, (Map) object );
return optionDialog.getOption(); return optionDialog.getOption();
} }

@ -14,20 +14,47 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel;
public class LeafOptionDialog extends JDialog public class LeafOptionDialog<KeyClass extends Object> extends JDialog
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Map<Object, Object> map = null; private static final String CANCEL_LABEL = "Cancelar";
private Object selected = null; private final JLabel labelMessage = new JLabel();
private Map<KeyClass, ? extends Object> map = null;
private KeyClass selected = null;
private String message = null;
/** Creates a new instance of JCalendarDialog */ /** Creates a new instance of JCalendarDialog */
public LeafOptionDialog(JFrame parentFrame, JComponent parent, Map<Object, Object> map) public LeafOptionDialog(JFrame parentFrame, JComponent parent, Map<KeyClass, ? extends Object> map)
{ {
super( parentFrame ); super( parentFrame );
this.map = map == null ? new HashMap<Object, Object>() : map; startup( parent, map );
}
/** Creates a new instance of JCalendarDialog */
public LeafOptionDialog(JFrame parentFrame, JComponent parent, Map<KeyClass, ? extends Object> map, String message)
{
super( parentFrame );
this.message = message;
startup( parent, map );
}
private void startup( JComponent parent, Map<KeyClass, ? extends Object> map )
{
if( map == null )
{
this.map = new HashMap<KeyClass, Object>();
}
else
{
this.map = map;
}
setModal( true ); setModal( true );
setupComponents(); setupComponents();
setUndecorated( true ); setUndecorated( true );
@ -37,12 +64,15 @@ public class LeafOptionDialog extends JDialog
private void setupComponents() private void setupComponents()
{ {
Set<Object> keySet = map.keySet(); Set<KeyClass> keySet = map.keySet();
Iterator<KeyClass> iterator = keySet.iterator();
KeyClass current = null;
double[] cols = new double[] { double[] cols = new double[] {
TableLayout.MINIMUM TableLayout.MINIMUM
}; };
double[] rows = new double[keySet.size() + 1]; double[] rows = new double[message == null ? 0 : 1 + keySet.size() + 1];
for( int i = 0; i < keySet.size() + 1; ++i ) for( int i = 0; i < rows.length; ++i )
{ {
rows[i] = TableLayout.MINIMUM; rows[i] = TableLayout.MINIMUM;
} }
@ -50,31 +80,34 @@ public class LeafOptionDialog extends JDialog
layout.setVGap( 3 ); layout.setVGap( 3 );
setContentPane( new LeafGradientPanel() ); setContentPane( new LeafGradientPanel() );
getContentPane().setLayout( layout ); getContentPane().setLayout( layout );
Iterator<Object> iterator = keySet.iterator();
Object current = null;; int shift = 0;
for( int i = 0; i < keySet.size() && iterator.hasNext(); ++i ) if( message != null )
{
labelMessage.setText( message );
getContentPane().add( labelMessage, new TableLayoutConstraints( 0, shift++ ) );
}
for( int i = 0; i < keySet.size() && iterator.hasNext(); ++i )
{ {
current = iterator.next(); current = iterator.next();
LeafInputField<Object> component = new LeafInputField<Object>(); LeafInputField<Object> component = new LeafInputField<Object>();
component.setObject( map.get( current ) ); component.setObject( map.get( current ) );
getContentPane().add( component, new TableLayoutConstraints( 0, i ) ); getContentPane().add( component, new TableLayoutConstraints( 0, i + shift ) );
addListenerToComponent( component ); addListenerToComponent( component );
} }
LeafInputField<String> cancelButton = new LeafInputField<String>(); LeafInputField<String> cancelButton = new LeafInputField<String>();
cancelButton.setObject( "Cancelar" ); cancelButton.setObject( CANCEL_LABEL );
getContentPane().add( cancelButton, new TableLayoutConstraints( 0, keySet.size() ) ); getContentPane().add( cancelButton, new TableLayoutConstraints( 0, keySet.size() + shift ) );
addListenerToComponent( cancelButton ); addListenerToComponent( cancelButton );
((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() ); ((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() );
setSize( layout.preferredLayoutSize( this.getContentPane() ) ); setSize( layout.preferredLayoutSize( this.getContentPane() ) );
} }
private KeyClass getKeyForValue( Object value )
private Object getKeyForValue( Object value )
{ {
if( value != null && map.containsValue( value ) ) if( value != null && map.containsValue( value ) )
{ {
for( Object key : map.keySet() ) for( KeyClass key : map.keySet() )
{ {
if( map.get( key ).equals( value ) ) if( map.get( key ).equals( value ) )
{ {
@ -127,7 +160,7 @@ public class LeafOptionDialog extends JDialog
} ); } );
} }
public Object getOption() public KeyClass getOption()
{ {
return selected; return selected;
} }

@ -64,7 +64,7 @@ public class ProcessoAccoesPanel extends JPanel
private final JPanel cardPanel = new JPanel(); private final JPanel cardPanel = new JPanel();
private final JPanel controlPanel = new JPanel(); // private final JPanel controlPanel = new JPanel();
private final CardLayout cardLayout = new CardLayout(); private final CardLayout cardLayout = new CardLayout();
@ -92,7 +92,9 @@ public class ProcessoAccoesPanel extends JPanel
CREATE_CONSULTA, CREATE_CONSULTA_MARCACAO CREATE_CONSULTA, CREATE_CONSULTA_MARCACAO
}, onChange = "") }, onChange = "")
public final LeafButton buttonNovoProcessoConsulta = new LeafButton( "Nova Consulta" ); public final LeafButton buttonNovoProcessoConsulta = new LeafButton( "Nova Consulta" );
@ActionActivation(onSelect = { CREATE_EXAME,CREATE_EXAME_MARCACAO }, onChange = "") @ActionActivation(onSelect = {
CREATE_EXAME, CREATE_EXAME_MARCACAO
}, onChange = "")
public final LeafButton buttonNovoProcessoExame = new LeafButton( "Novo Exame" ); public final LeafButton buttonNovoProcessoExame = new LeafButton( "Novo Exame" );
// consulta // consulta
@ -134,8 +136,6 @@ public class ProcessoAccoesPanel extends JPanel
// control // control
public final LeafButton buttonControlClose = new LeafButton( "Fechar" );
public ProcessoAccoesPanel(SIPRPWindow parentWindow) public ProcessoAccoesPanel(SIPRPWindow parentWindow)
{ {
this.parentWindow = parentWindow; this.parentWindow = parentWindow;
@ -149,20 +149,10 @@ public class ProcessoAccoesPanel extends JPanel
TableLayout layout = new TableLayout( new double[] { TableLayout layout = new TableLayout( new double[] {
TableLayout.FILL TableLayout.FILL
}, new double[] { }, new double[] {
TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM TableLayout.FILL
} ); } );
this.setLayout( layout ); this.setLayout( layout );
cardPanel.setLayout( cardLayout ); 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() private void setupComponents()
@ -186,16 +176,7 @@ public class ProcessoAccoesPanel extends JPanel
cardPanel.add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME ); cardPanel.add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME );
cardPanel.add( panelExame, PANEL_EXAME_NAME ); cardPanel.add( panelExame, PANEL_EXAME_NAME );
cardPanel.add( panelExameMarcacao, PANEL_EXAME_MARCACAO_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( cardPanel, new TableLayoutConstraints( 0, 0 ) );
this.add( new JPanel(), new TableLayoutConstraints( 0, 1 ) );
this.add( controlPanel, new TableLayoutConstraints( 0, 2 ) );
} }
@LeafUIActionBinding(action = { @LeafUIActionBinding(action = {
@ -262,7 +243,7 @@ public class ProcessoAccoesPanel extends JPanel
break; break;
} }
} }
buttonNovoConsultaMarcacao.setEnabled( !marcacaoAberta && !new Integer(MedicinaConstants.ESTADO_REALIZADO).equals( consulta.getEstado() )); buttonNovoConsultaMarcacao.setEnabled( !marcacaoAberta && !new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( consulta.getEstado() ) );
cardLayout.show( cardPanel, PANEL_CONSULTA_NAME ); cardLayout.show( cardPanel, PANEL_CONSULTA_NAME );
} }
else else
@ -372,8 +353,6 @@ public class ProcessoAccoesPanel extends JPanel
private void setupStartPanel() private void setupStartPanel()
{ {
// panelStart.setBorder( BorderFactory.createTitledBorder(
// BorderFactory.createEtchedBorder(), "none" ) );
} }
private void setupTrabalhadorPanel() private void setupTrabalhadorPanel()
@ -393,7 +372,15 @@ public class ProcessoAccoesPanel extends JPanel
private void setupConsultaMarcacaoPanel() private void setupConsultaMarcacaoPanel()
{ {
setupSimpleActionsPanel( panelConsultaMarcacao, buttonNovoConsultaMarcacaoEmail, buttonNovoConsultaMarcacaoObservacoes, buttonConsultaMarcacaoRealizar, buttonConsultaMarcacaoDesmarcar, buttonConsultaMarcacaoFaltou, new JPanel() ); JPanel consultaMarcacaoUpperPanel = new JPanel();
JPanel consultaMarcacaoLowerPanel = new JPanel();
setupSimpleActionsPanel( consultaMarcacaoUpperPanel, buttonNovoConsultaMarcacaoEmail, buttonNovoConsultaMarcacaoObservacoes );
setupSimpleActionsPanel( consultaMarcacaoLowerPanel, buttonConsultaMarcacaoRealizar, buttonConsultaMarcacaoDesmarcar, buttonConsultaMarcacaoFaltou);
TableLayout consultaMarcacaoLayout = new TableLayout(new double[]{TableLayout.FILL}, new double[]{TableLayout.MINIMUM, TableLayout.FILL,TableLayout.MINIMUM});
panelConsultaMarcacao.setLayout( consultaMarcacaoLayout );
panelConsultaMarcacao.add( consultaMarcacaoUpperPanel, new TableLayoutConstraints(0,0) );
panelConsultaMarcacao.add( new JPanel(), new TableLayoutConstraints(0,1) );
panelConsultaMarcacao.add( consultaMarcacaoLowerPanel, new TableLayoutConstraints(0,2) );
} }
private void setupExamePanel() private void setupExamePanel()

@ -52,6 +52,7 @@ import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes; import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes;
import siprp.database.cayenne.objects.TrabalhadoresProcesso; import siprp.database.cayenne.objects.TrabalhadoresProcesso;
import siprp.logic.SIPRPLogic.LeafUIActionBinding; import siprp.logic.SIPRPLogic.LeafUIActionBinding;
import siprp.medicina.processo.ProcessoConstants;
import siprp.ui.SIPRPWindow; import siprp.ui.SIPRPWindow;
import siprp.ui.SIPRPWindow.ActionActivation; import siprp.ui.SIPRPWindow.ActionActivation;
@ -425,6 +426,18 @@ public class ProcessoDadosPanel extends JPanel
} }
} }
@LeafUIActionBinding(action = CREATE_PROCESSO)
public void setForNewProcesso( TrabalhadoresProcesso processo )
{
HashMap<Integer, String> tipos = processo.getMotivos();
LeafOptionDialog<Integer> option = new LeafOptionDialog<Integer>(getParentFrame(), this, tipos, "Escolha o tipo de processo:");
Integer chosen = option.getOption();
if(chosen != null)
{
processo.setMotivo( chosen );
}
}
@LeafUIActionBinding(action = CREATE_CONSULTA) @LeafUIActionBinding(action = CREATE_CONSULTA)
public void setForNewConsulta( TrabalhadoresConsultas consulta ) public void setForNewConsulta( TrabalhadoresConsultas consulta )
{ {

@ -368,7 +368,7 @@ public class ProcessoTreePanel extends JPanel
private DefaultMutableTreeNode getSelectedNode() private DefaultMutableTreeNode getSelectedNode()
{ {
DefaultMutableTreeNode result = null; DefaultMutableTreeNode result = null;
Object[] nodes = mainTree.getSelectionPath().getPath(); Object[] nodes = mainTree.getSelectionPath() == null ? null : mainTree.getSelectionPath().getPath();
if( nodes != null && nodes.length > 0 && nodes[nodes.length - 1] instanceof DefaultMutableTreeNode ) if( nodes != null && nodes.length > 0 && nodes[nodes.length - 1] instanceof DefaultMutableTreeNode )
{ {
result = (DefaultMutableTreeNode) nodes[nodes.length - 1]; result = (DefaultMutableTreeNode) nodes[nodes.length - 1];

Loading…
Cancel
Save