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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 18 years ago
parent f70ff599d8
commit 07b9c89c19

@ -128,6 +128,7 @@ public class TrabalhadoresEcds extends _TrabalhadoresEcds implements MedicinaCon
setEstado( ESTADO_POR_REALIZAR );
}
}
grupos.order();
return grupos;
}

@ -70,6 +70,7 @@ public class TrabalhadoresEcdsDatas extends _TrabalhadoresEcdsDatas implements M
}
}
}
grupos.order();
return grupos;
}

@ -489,6 +489,7 @@ public class MedicinaProcessoLogic extends SIPRPLogic
currentExameMarcacao.setToPrestadores( getPrestador(false) );
currentExameMarcacao.setToAnalisador( getAnalisador() );
currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
runActionLater( SAVE_EXAME_MARCACAO );
return currentExameMarcacao;
}

@ -172,10 +172,10 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
{
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 );
outerContour = new GradientPaint( width / 4, 0, Color.GRAY, width, 0, this.getParent().getBackground() );
outerReversedContour = new GradientPaint( 15, 0, this.getParent().getBackground(), width / 4, 0, Color.GRAY );
innerContour = new GradientPaint( width / 4, 0, Color.LIGHT_GRAY, width, 0, this.getParent().getBackground() );
innerReversedContour = new GradientPaint( 15, 0, this.getParent().getBackground(), width / 4, 0, Color.LIGHT_GRAY );
gradient = new GradientPaint( 0, 0, startColor, width, height, endColor );
}

@ -3,6 +3,7 @@ package siprp.medicina.processo.ui;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
@ -16,13 +17,17 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JSeparator;
public class LeafOptionDialog<KeyClass extends Object> extends JDialog
{
private static final Dimension OPTION_SIZE = new Dimension(0,20);
private static final Dimension BUTTON_SIZE = new Dimension(0,20);
private static final long serialVersionUID = 1L;
private static final String CANCEL_LABEL = "Cancelar";
private static String okLabel = "Ok";
private final JLabel labelMessage = new JLabel();
@ -37,64 +42,46 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
private List<KeyClass> selected = new ArrayList<KeyClass>();
private Map<KeyClass, Boolean> mapEnabledForKey = new HashMap<KeyClass, Boolean>();
private Map<KeyClass, Boolean> mapChosenForKey = new HashMap<KeyClass, Boolean>();
private String message = null;
private boolean ordered = false;
public LeafOptionDialog(Map<KeyClass, ? extends Object> map)
{
super( );
startup( map, null );
}
public LeafOptionDialog( Map<KeyClass, ? extends Object> map, String message, boolean cancelActive)
{
super( );
this.cancelActive = cancelActive;
this.message = message;
startup( map, null );
}
public LeafOptionDialog( Map<KeyClass, ? extends Object> map, String message, String okButton, boolean cancelActive)
{
super( );
this.cancelActive = cancelActive;
this.message = message;
this.okLabel = okButton;
super();
startup( map, null );
}
public LeafOptionDialog(Map<KeyClass, ? extends Object> map, String message)
{
super( );
super();
this.message = message;
startup( map, null );
}
public LeafOptionDialog(OrderedMap<KeyClass> orderedMap, String message)
public LeafOptionDialog(OrderedMap<KeyClass> orderedMap, Map<KeyClass, Boolean> chosen, Map<KeyClass, Boolean> enabled, String message, String okButton)
{
super( );
ordered = true;
this.message = message;
startup( null, orderedMap );
}
/** Creates a new instance of JCalendarDialog */
public LeafOptionDialog(Map<KeyClass, ? extends Object> map, String message, String okButton)
{
super( );
this.message = message;
this.okLabel = okButton;
startup( map, null );
}
/** Creates a new instance of JCalendarDialog */
public LeafOptionDialog(OrderedMap<KeyClass> orderedMap, String message, String okButton)
{
super( );
super();
ordered = true;
this.message = message;
this.okLabel = okButton;
this.mapChosenForKey = chosen;
this.mapEnabledForKey = enabled;
if( chosen != null )
{
for( KeyClass key : chosen.keySet() )
{
Boolean isChosen = chosen.get( key );
if( isChosen != null && isChosen )
{
selected.add( key );
}
}
}
startup( null, orderedMap );
}
@ -116,24 +103,23 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
{
this.orderedMap = orderedMap;
}
setupComponents( map == null ? orderedMap.keySet() : map.keySet(), map == null ? true : false );
setupComponents( map == null ? orderedMap.iterator() : map.keySet().iterator(), map == null ? orderedMap.rows() : map.keySet().size(), map == null ? true : false );
setModal( true );
setUndecorated( true );
setVisible( true );
}
private void setupComponents( Set<KeyClass> keySet, boolean ordered )
private void setupComponents( Iterator<KeyClass> iterator, Integer size, boolean ordered )
{
Iterator<KeyClass> iterator = keySet.iterator();
KeyClass current = null;
double[] cols = new double[] {
TableLayout.FILL
};
double[] rows = new double[(message == null ? 0 : 1) + keySet.size() + (cancelActive ? 1 : 0)];
double[] rows = new double[(message == null ? 0 : 2) + size + (cancelActive ? 2 : 0)];
for( int i = 0; i < rows.length; ++i )
{
rows[i] = TableLayout.FILL;
rows[i] = TableLayout.PREFERRED;
}
TableLayout layout = new TableLayout( cols, rows );
layout.setVGap( 3 );
@ -145,8 +131,9 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
{
labelMessage.setText( message );
getContentPane().add( labelMessage, new TableLayoutConstraints( 0, shift++ ) );
getContentPane().add( new JSeparator(), new TableLayoutConstraints( 0, shift++ ) );
}
for( int i = 0; i < keySet.size() && iterator.hasNext(); ++i )
for( int i = 0; i < size && iterator.hasNext(); ++i )
{
current = iterator.next();
LeafInputField<Object> component = new LeafInputField<Object>();
@ -161,15 +148,24 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
value = map.get( current );
}
component.setObject( value );
component.setClickable( true );
Boolean isChosen = mapChosenForKey.get( current );
component.setSelected( isChosen != null && isChosen );
Boolean isEnabled = mapEnabledForKey.get( current );
component.setClickable( isEnabled != null && isEnabled );
component.setPreferredSize( OPTION_SIZE );
getContentPane().add( component, new TableLayoutConstraints( 0, i + shift ) );
addListenerToComponent( component );
}
if( cancelActive )
{
getContentPane().add( new JSeparator(), new TableLayoutConstraints( 0, size + shift++ ) );
submitButton.setObject( ordered ? okLabel : CANCEL_LABEL );
submitButton.setClickable( true );
getContentPane().add( submitButton, new TableLayoutConstraints( 0, keySet.size() + shift ) );
submitButton.setPreferredSize( BUTTON_SIZE );
getContentPane().add( submitButton, new TableLayoutConstraints( 0, size + shift ) );
addListenerToComponent( submitButton );
}
((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() );

@ -1,11 +1,16 @@
package siprp.medicina.processo.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import com.evolute.utils.sql.expression.Or;
public class OrderedMap<KeyClass extends Object>
{
private static final long serialVersionUID = 1L;
@ -75,9 +80,9 @@ public class OrderedMap<KeyClass extends Object>
return order.isEmpty() ? null : order.get( 0 );
}
public Set<KeyClass> keySet()
public Iterator<KeyClass> iterator()
{
return map.keySet();
return order.iterator();
}
public boolean containsKey( KeyClass key )
@ -111,5 +116,38 @@ public class OrderedMap<KeyClass extends Object>
order.remove( key );
return map.remove( key );
}
/**
* Orders by first column (rows compared as strings)
*/
public void order()
{
if(order != null && order.size() > 0)
{
HashMap<Object, KeyClass> keyForObject = new HashMap<Object, KeyClass>();
List<String> sortedList = new ArrayList<String>();
for(KeyClass key : order)
{
List<Object> row = map.get( key );
Object value = null;
if( row != null && row.size() > 0)
{
value = row.get( 0 );
keyForObject.put( value.toString() , key );
sortedList.add( value.toString() );
}
}
if(sortedList.size() == order.size())
{
Collections.sort( sortedList );
Vector<KeyClass> newOrder = new Vector<KeyClass>();
for(String value : sortedList)
{
newOrder.add( keyForObject.get( value ) );
}
order = newOrder;
}
}
}
}

@ -324,6 +324,8 @@ public class ProcessoAccoesPanel extends JPanel
{
if( exame != null )
{
boolean porMarcar = new Integer( MedicinaConstants.ESTADO_POR_MARCAR ).equals( exame.getEstado() );
buttonNovoExameMarcacao.setEnabled( porMarcar );
cardLayout.show( cardPanel, PANEL_EXAME_NAME );
}
else

@ -39,6 +39,8 @@ import info.clearthought.layout.TableLayoutConstraints;
import java.awt.CardLayout;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
@ -58,6 +60,7 @@ 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.MedicinaConstants;
import siprp.medicina.processo.mail.MailDialog;
import siprp.ui.SIPRPWindow;
import siprp.ui.SIPRPWindow.ActionActivation;
@ -470,7 +473,22 @@ public class ProcessoDadosPanel extends JPanel
marcacao.setData( date );
OrderedMap<PrtGruposProtocolo> grupos = marcacao.getToTrabalhadoresEcds().getGruposExamesForPerfil();
LeafOptionDialog<PrtGruposProtocolo> gruposChosen = new LeafOptionDialog<PrtGruposProtocolo>( grupos, "Escolha os ECDs para esta marca" +ccedil + atilde + "o" , "Marcar »" );
Map<PrtGruposProtocolo, Boolean> gruposSelected = new HashMap<PrtGruposProtocolo, Boolean>();
Map<PrtGruposProtocolo, Boolean> gruposEnabled = new HashMap<PrtGruposProtocolo, Boolean>();
for(int row = 0; row < grupos.rows(); ++row)
{
List<Object> grupo = grupos.getValuesAt( row );
if( grupo != null && grupo.size() > 1)
{
String estado = grupo.get( 1 ).toString();
if(MedicinaConstants.ESTADOS_EXAME_STR[MedicinaConstants.ESTADO_POR_MARCAR].equals( estado ))
{
gruposSelected.put( grupos.getKeyForValue( grupo ), true );
gruposEnabled.put( grupos.getKeyForValue( grupo ), true );
}
}
}
LeafOptionDialog<PrtGruposProtocolo> gruposChosen = new LeafOptionDialog<PrtGruposProtocolo>( grupos, gruposSelected, gruposEnabled, "Escolha os ECDs para esta marca" +ccedil + atilde + "o" , "<html><font size=\"4\"><b>Marcar »</b></font></html>" );
for( PrtGruposProtocolo grupo : gruposChosen.getSelected() )
{
marcacao.marcarGrupoExames( grupo );

Loading…
Cancel
Save