Suporte para multiplos analisadores

git-svn-id: https://svn.coded.pt/svn/SIPRP@653 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 18 years ago
parent 604b7b7e51
commit f235ce51a8

@ -402,6 +402,7 @@
</db-key-generator>
</db-entity>
<db-entity name="trabalhadores_ecd" schema="public">
<db-attribute name="analisador_id" type="INTEGER" length="10"/>
<db-attribute name="ecd_id" type="INTEGER" length="10"/>
<db-attribute name="ecd_oficial_id" type="INTEGER" length="10"/>
<db-attribute name="enviado" type="CHAR" length="1"/>
@ -987,6 +988,9 @@
<db-relationship name="trabalhadoresConsultasDatasArray" source="prestadores" target="trabalhadores_consultas_datas" toMany="true">
<db-attribute-pair source="id" target="prestador_id"/>
</db-relationship>
<db-relationship name="trabalhadoresEcdArray" source="prestadores" target="trabalhadores_ecd" toMany="true">
<db-attribute-pair source="id" target="analisador_id"/>
</db-relationship>
<db-relationship name="trabalhadoresEcdsDatasArray1" source="prestadores" target="trabalhadores_ecds_datas" toMany="true">
<db-attribute-pair source="id" target="analisador_id"/>
</db-relationship>
@ -1068,6 +1072,9 @@
<db-relationship name="toTrabalhadoresConsultasDatas" source="trabalhadores_consultas_datas_observacoes" target="trabalhadores_consultas_datas" toMany="false">
<db-attribute-pair source="trabalhadores_consultas_datas_id" target="id"/>
</db-relationship>
<db-relationship name="toAnalisador" source="trabalhadores_ecd" target="prestadores" toMany="false">
<db-attribute-pair source="analisador_id" target="id"/>
</db-relationship>
<db-relationship name="toEcdOficial" source="trabalhadores_ecd" target="ecd_oficial" toMany="false">
<db-attribute-pair source="ecd_oficial_id" target="id"/>
</db-relationship>
@ -1188,6 +1195,7 @@
<obj-relationship name="toContactos" source="Prestadores" target="Contactos" db-relationship-path="toContactos"/>
<obj-relationship name="trabalhadoresConsultasArray" source="Prestadores" target="TrabalhadoresConsultas" db-relationship-path="trabalhadoresConsultasArray"/>
<obj-relationship name="trabalhadoresConsultasDatasArray" source="Prestadores" target="TrabalhadoresConsultasDatas" db-relationship-path="trabalhadoresConsultasDatasArray"/>
<obj-relationship name="trabalhadoresEcdArray" source="Prestadores" target="TrabalhadoresEcd" db-relationship-path="trabalhadoresEcdArray"/>
<obj-relationship name="trabalhadoresEcdsDatasArray" source="Prestadores" target="TrabalhadoresEcdsDatas" db-relationship-path="trabalhadoresEcdsDatasArray1"/>
<obj-relationship name="toPrestadores" source="PrestadoresGruposProtocolo" target="Prestadores" db-relationship-path="toPrestadores"/>
<obj-relationship name="toPrtGruposProtocolo" source="PrestadoresGruposProtocolo" target="PrtGruposProtocolo" db-relationship-path="toPrtGruposProtocolo"/>
@ -1215,6 +1223,7 @@
<obj-relationship name="trabalhadoresConsultasDatasObservacoesArray" source="TrabalhadoresConsultasDatas" target="TrabalhadoresConsultasDatasObservacoes" db-relationship-path="trabalhadoresConsultasDatasObservacoesArray"/>
<obj-relationship name="toTrabalhadoresConsultasDatas" source="TrabalhadoresConsultasDatasEmails" target="TrabalhadoresConsultasDatas" db-relationship-path="toTrabalhadoresConsultasDatas"/>
<obj-relationship name="toTrabalhadoresConsultasDatas" source="TrabalhadoresConsultasDatasObservacoes" target="TrabalhadoresConsultasDatas" db-relationship-path="toTrabalhadoresConsultasDatas"/>
<obj-relationship name="toAnalisador" source="TrabalhadoresEcd" target="Prestadores" db-relationship-path="toAnalisador"/>
<obj-relationship name="toEcdOficial" source="TrabalhadoresEcd" target="EcdOficial" db-relationship-path="toEcdOficial"/>
<obj-relationship name="toPrtTiposElementosProtocolo" source="TrabalhadoresEcd" target="PrtTiposElementosProtocolo" db-relationship-path="toPrtTiposElementosProtocolo"/>
<obj-relationship name="toTrabalhadoresEcdsDatas" source="TrabalhadoresEcd" target="TrabalhadoresEcdsDatas" db-relationship-path="toTrabalhadoresEcdsDatas"/>

@ -4,6 +4,7 @@ import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
@ -11,6 +12,8 @@ import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -30,8 +33,10 @@ import javax.swing.SwingUtilities;
import siprp.medicina.processo.ui.OrderedMap;
public class LeafInputField<ObjClass extends Object> extends JPanel implements FocusListener, MouseListener
public class LeafInputField<ObjClass extends Object> extends JPanel implements FocusListener, MouseListener, PropertyChangeListener
{
private static final Dimension SIZE = new Dimension( 0, 20 );
public static final String PROPERTY_CHANGED_CONSTANT = "LEAF_INPUT_PROPERTY_CHANGED";
public static final String PROPERTY_CHANGED_CLICK = "LEAF_PROPERTY_CHANGED_CLICK";
private static final long serialVersionUID = 1L;
@ -47,7 +52,7 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
private Color background = null;
private Color startColor = null;
private Color endColor = null;
private Color highLightColor = Color.GREEN.brighter().brighter();
private Color highLightColor = new Color( 180, 255, 180 );
private Object selectedOption = null;
@ -78,12 +83,12 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
{
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;
setObject( null );
}
public boolean isCollapseOptions()
@ -109,15 +114,23 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
private String getStringFromUser()
{
LeafTextDialog textDialog = new LeafTextDialog( getParentFrame(), this, (String) object, false);
LeafTextDialog textDialog = new LeafTextDialog( getParentFrame(), this, (String) object, false );
return textDialog.getText();
}
private Object getOptionFromUser()
{
LeafOptionDialog<Object> optionDialog = new LeafOptionDialog<Object>( (Map) object );
return optionDialog.getOption();
if( object instanceof Map )
{
LeafOptionDialog<Object> optionDialog = new LeafOptionDialog<Object>( (Map) object, null );
return optionDialog.getOption();
}
else if( object instanceof OrderedMap )
{
LeafOptionDialog<Object> optionDialog = new LeafOptionDialog<Object>( (OrderedMap<Object>) object, null, null, null, null );
return optionDialog.getOption();
}
return null;
}
private Date getDateFromUser()
@ -212,10 +225,14 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
background = selected ? highLightColor : cold;
repaint();
}
public void setEditable( boolean editable )
{
isEditable = editable;
if( !editable )
{
setMouseOver( false );
}
repaint();
}
@ -227,6 +244,10 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
public void setClickable( boolean clickable )
{
isClickable = clickable;
if( !clickable )
{
setMouseOver( false );
}
repaint();
}
@ -292,26 +313,46 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
{
if( i % 2 == 0 )
{
List<Object> values = map.getValuesAt( a++ );
List<Object> values = map.getRow( a++ );
for( int j = 0, b = 0; j < cols.length; ++j )
{
JComponent comp = null;
if( j % 2 == 0 )
{
Object value = values.get( b++ );
comp = new JLabel( value == null ? " " : value.toString() );
LeafInputField<Object> leaf;
if( value instanceof LeafInputField )
{
leaf = (LeafInputField<Object>) value;
}
else
{
leaf = new LeafInputField<Object>();
leaf.setObject( value );
if( j > 1 )
{
leaf.setEditable( isEditable );
}
}
comp = leaf;
theeze.add( comp );
}
else
{
comp = new JSeparator( JSeparator.VERTICAL );
JSeparator sep = new JSeparator( JSeparator.VERTICAL );
sep.setForeground( cold );
comp = sep;
}
thiz.add( comp, new TableLayoutConstraints( j, i ) );
}
}
else
{
thiz.add( new JSeparator(), new TableLayoutConstraints( 0, i, cols.length - 1, i ) );
JSeparator sep = new JSeparator();
sep.setForeground( cold );
thiz.add( sep, new TableLayoutConstraints( 0, i, cols.length - 1, i ) );
}
}
}
@ -319,7 +360,7 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
private void setSelectedObject( Object key )
{
selectedOption = key;
if( object != null && thiz != null && selectedOption != null )
if( object != null && thiz != null /*&& selectedOption != null */)
{
if( object instanceof Map )
{
@ -351,7 +392,7 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
}
}
}
public Object getSelectedObject()
{
return selectedOption;
@ -387,9 +428,18 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
thiz = new JPanel();
setSelectedObject( selectedOption );
}
else if( object instanceof LeafInputField )
{
setObject( (ObjClass) ((LeafInputField) object).getObject(), ((LeafInputField) object).getSelectedObject() );
}
else
{
thiz = new JLabel( object.toString() );
String toString = object.toString();
if( "".equals( toString ) )
{
toString = " ";
}
thiz = new JLabel( toString );
}
}
else
@ -407,26 +457,80 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
private void reListen()
{
if( thiz != null )
removeListeners();
if( theeze != null && !collapseOptions && !theeze.isEmpty() )
{
for( JComponent current : theeze )
{
if( current instanceof LeafInputField )
{
current.addFocusListener( (LeafInputField) current );
current.addMouseListener( (LeafInputField) current );
current.addPropertyChangeListener( PROPERTY_CHANGED_CONSTANT, this );
}
}
}
else
{
thiz.addFocusListener( this );
thiz.addMouseListener( this );
}
}
private void removeListeners()
{
removeListerensFrom( thiz );
if( theeze != null )
{
for( JComponent comp : theeze )
{
removeListerensFrom( comp );
}
}
}
private void removeListerensFrom( JComponent comp )
{
if( comp != null )
{
FocusListener[] allFocus = thiz.getFocusListeners();
if( allFocus != null )
{
for( FocusListener focusListener : allFocus )
{
comp.removeFocusListener( focusListener );
}
}
MouseListener[] allMouse = thiz.getMouseListeners();
if( allMouse != null )
{
for( MouseListener mouseListener : allMouse )
{
comp.removeMouseListener( mouseListener );
}
}
}
}
private void reLayout()
{
if( thiz != null )
{
SwingUtilities.invokeLater(new Runnable(){
{
SwingUtilities.invokeLater( new Runnable()
{
@Override
public void run()
{
if( layout == null )
{
layout = new TableLayout(new double []{TableLayout.FILL}, new double[]{TableLayout.FILL});
layout = new TableLayout( new double[] {
TableLayout.FILL
}, new double[] {
TableLayout.FILL
} );
LeafInputField.this.setLayout( layout );
}else
}
else
{
removeAll();
}
@ -434,7 +538,8 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
revalidate();
repaint();
}
});
} );
thiz.setOpaque( false );
}
}
@ -458,50 +563,61 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
@Override
public void mousePressed( MouseEvent e )
{
ObjClass obj = object;
if( obj != null && isEditable )
Object old = null;
if( object != null && isEditable )
{
if( obj instanceof Date )
if( object instanceof Date )
{
obj = (ObjClass) getDateFromUser();
old = object;
setObject( (ObjClass) getDateFromUser() );
firePropertyChange( PROPERTY_CHANGED_CONSTANT, old, object );
}
else if( obj instanceof Map && collapseOptions )
else if( object instanceof Map && collapseOptions )
{
old = selectedOption;
ObjClass out = (ObjClass) getOptionFromUser();
setSelectedObject( out );
obj = object;
setObject( object, out );
firePropertyChange( PROPERTY_CHANGED_CONSTANT, old, selectedOption );
}
else if( obj instanceof OrderedMap )
else if( object instanceof OrderedMap && collapseOptions )
{
old = selectedOption;
ObjClass out = (ObjClass) getOptionFromUser();
setObject( object, out );
firePropertyChange( PROPERTY_CHANGED_CONSTANT, old, object );
}
else if( obj instanceof String )
else if( object instanceof OrderedMap && !collapseOptions )
{
obj = (ObjClass) getStringFromUser();
// old = selectedOption;
// ObjClass out = (ObjClass) getOptionFromUser();
// setObject( object, out );
// firePropertyChange( PROPERTY_CHANGED_CONSTANT, old, object );
}
if( obj != null )
else if( object instanceof String )
{
firePropertyChange( PROPERTY_CHANGED_CONSTANT, object, obj );
setObject( obj );
old = object;
setObject( (ObjClass) getStringFromUser() );
firePropertyChange( PROPERTY_CHANGED_CONSTANT, old, object );
}
}
if( isClickable )
{
firePropertyChange( PROPERTY_CHANGED_CLICK, false, true );
}
// setObject( object, selectedOption );
}
@Override
public void mouseExited( MouseEvent e )
{
background = (!highLighted && (isEditable || isClickable)) ? cold : background;
setMouseOver( false );
repaint();
}
@Override
public void mouseEntered( MouseEvent e )
{
background = (!highLighted && (isEditable || isClickable)) ? hot : background;
setMouseOver( true );
repaint();
}
@ -509,4 +625,22 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
public void mouseClicked( MouseEvent e )
{
}
private void setMouseOver( boolean mouseOver )
{
if( mouseOver )
{
background = (!highLighted && (isEditable || isClickable)) ? hot : background;
}
else
{
background = (!highLighted && (isEditable || isClickable)) ? cold : background;
}
}
@Override
public void propertyChange( PropertyChangeEvent evt )
{
firePropertyChange( PROPERTY_CHANGED_CONSTANT, evt.getOldValue(), evt.getNewValue() );
}
}

@ -73,10 +73,7 @@ public class LeafLogic
public void runAction( String actionName )
{
for( LeafWindow window : registeredWindows )
{
window.runAction( actionName );
}
runAction( actionName, null );
}
public void runAction( String actionName, Object argument )

@ -0,0 +1,22 @@
package leaf;
import javax.swing.plaf.metal.MetalLookAndFeel;
public class LeafLookAndFeel extends MetalLookAndFeel
{
private static final long serialVersionUID = 1L;
@Override
public String getName()
{
return "LEAF";
}
@Override
public String getDescription()
{
return "Evolute's LEAF Look And Feel";
}
}

@ -17,7 +17,11 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.ScrollPaneConstants;
import siprp.medicina.processo.ui.OrderedMap;
@ -26,14 +30,20 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
private static final Dimension OPTION_SIZE = new Dimension( 200, 20 );
private static final Dimension BUTTON_SIZE = new Dimension( 200, 20 );
private static final int MAX_VISIBLE_OPTIONS = 5;
private static final long serialVersionUID = 1L;
private static final String CANCEL_LABEL = "Cancelar";
private String CANCEL_LABEL = "Cancelar";
private static String okLabel = "Ok";
private String okLabel = null;
private final JLabel labelMessage = new JLabel();
private final JPanel optionsPanel = new JPanel();
private final JScrollPane optionsScrollPane = new JScrollPane();
private boolean cancelActive = true;
private LeafInputField<String> submitButton = new LeafInputField<String>();
@ -52,13 +62,6 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
private boolean ordered = false;
public LeafOptionDialog(Map<KeyClass, ? extends Object> map)
{
super();
cancelActive = false;
startup( map, null );
}
public LeafOptionDialog(Map<KeyClass, ? extends Object> map, String message)
{
super();
@ -79,6 +82,7 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
ordered = true;
this.message = message;
okLabel = okButton;
cancelActive = okButton != null;
this.mapChosenForKey = chosen == null ? new HashMap<KeyClass, Boolean>() : chosen;
this.mapEnabledForKey = enabled == null ? new HashMap<KeyClass, Boolean>() : chosen;
if( chosen != null )
@ -121,12 +125,10 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
private void setupComponents( Iterator<KeyClass> iterator, Integer size, boolean ordered )
{
KeyClass current = null;
double[] cols = new double[] {
TableLayout.PREFERRED
};
double[] rows = new double[(message == null ? 0 : 2) + size + (cancelActive ? 2 : 0)];
double[] rows = new double[(message == null ? 0 : 2) + 1 + (cancelActive ? 2 : 0)];
for( int i = 0; i < rows.length; ++i )
{
rows[i] = TableLayout.PREFERRED;
@ -143,6 +145,36 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
getContentPane().add( labelMessage, new TableLayoutConstraints( 0, shift++ ) );
getContentPane().add( new JSeparator(), new TableLayoutConstraints( 0, shift++ ) );
}
setupOptionsComponents( iterator, size );
getContentPane().add( optionsScrollPane, new TableLayoutConstraints( 0, shift++ ) );
if( cancelActive )
{
getContentPane().add( new JSeparator(), new TableLayoutConstraints( 0, shift++ ) );
submitButton.setObject( ordered ? okLabel : CANCEL_LABEL );
submitButton.setClickable( true );
submitButton.setPreferredSize( BUTTON_SIZE );
getContentPane().add( submitButton, new TableLayoutConstraints( 0, shift++ ) );
addListenerToComponent( submitButton );
}
((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() );
setSize( layout.preferredLayoutSize( this.getContentPane() ) );
setLocationRelativeTo( getParent() );
}
private void setupOptionsComponents( Iterator<KeyClass> iterator, Integer size )
{
double[] cols = new double[] {
TableLayout.PREFERRED
};
double[] rows = new double[size];
for( int i = 0; i < rows.length; ++i )
{
rows[i] = TableLayout.PREFERRED;
}
TableLayout layout = new TableLayout( cols, rows );
layout.setVGap( 3 );
optionsPanel.setLayout( layout );
KeyClass current = null;
for( int i = 0; i < size && iterator.hasNext(); ++i )
{
current = iterator.next();
@ -166,21 +198,17 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
component.setClickable( isEnabled == null || isEnabled );
component.setPreferredSize( OPTION_SIZE );
getContentPane().add( component, new TableLayoutConstraints( 0, i + shift ) );
optionsPanel.add( component, new TableLayoutConstraints( 0, i ) );
addListenerToComponent( component );
}
if( cancelActive )
{
getContentPane().add( new JSeparator(), new TableLayoutConstraints( 0, size + shift++ ) );
submitButton.setObject( ordered ? okLabel : CANCEL_LABEL );
submitButton.setClickable( true );
submitButton.setPreferredSize( BUTTON_SIZE );
getContentPane().add( submitButton, new TableLayoutConstraints( 0, size + shift ) );
addListenerToComponent( submitButton );
}
((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() );
setSize( layout.preferredLayoutSize( this.getContentPane() ) );
setLocationRelativeTo( getParent() );
optionsScrollPane.setViewportView( optionsPanel );
optionsScrollPane.setHorizontalScrollBarPolicy( ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );
JScrollBar verticalScrollBar = optionsScrollPane.getVerticalScrollBar();
verticalScrollBar.setUnitIncrement( (int) OPTION_SIZE.getHeight() + 3 );
optionsScrollPane.setVerticalScrollBar( verticalScrollBar );
optionsScrollPane.setVerticalScrollBarPolicy( size > MAX_VISIBLE_OPTIONS ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS : ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER );
optionsScrollPane.setPreferredSize( new Dimension((int) OPTION_SIZE.getWidth() + 10 , size > MAX_VISIBLE_OPTIONS ? (MAX_VISIBLE_OPTIONS * ((int) (OPTION_SIZE.getHeight() + 3 )) ) : (size * ((int) (OPTION_SIZE.getHeight() + 3 )) ) ));
}
private KeyClass getKeyForValue( Object value )
@ -206,7 +234,6 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
{
component.addPropertyChangeListener( new PropertyChangeListener()
{
@Override
public void propertyChange( PropertyChangeEvent e )
{
@ -215,22 +242,25 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
LeafInputField<Object> source = (LeafInputField<Object>) e.getSource();
if( LeafInputField.PROPERTY_CHANGED_CLICK.equals( e.getPropertyName() ) )
{
Object value = source.getObject();
if( value != null )
{
KeyClass key = getKeyForValue( value );
if( selected.contains( key ) )
if( !source.equals( submitButton ) )
{
selected.remove( key );
source.setSelected( false );
}
else
Object value = source.getObject();
if( value != null )
{
selected.add( key );
source.setSelected( true );
KeyClass key = getKeyForValue( value );
if( selected.contains( key ) )
{
selected.remove( key );
source.setSelected( false );
}
else
{
selected.add( key );
source.setSelected( true );
}
}
}
if( !ordered || source.equals( submitButton ) )
if( okLabel == null || source.equals( submitButton ) )
{
close();
}

@ -0,0 +1,18 @@
package leaf;
public class LeafRuntimeException extends RuntimeException
{
private static final long serialVersionUID = 1L;
private boolean abort = false;
public LeafRuntimeException( boolean all )
{
this.abort = all;
}
public boolean isAbort()
{
return abort;
}
}

@ -0,0 +1,16 @@
package leaf;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
public class LeafScrollBar extends JScrollPane
{
private static final long serialVersionUID = 1L;
public void paintComponent()
{
System.out.println("");
}
}

@ -0,0 +1,166 @@
package leaf;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import siprp.medicina.processo.ui.OrderedMap;
import com.evolute.utils.tables.BaseTableModel;
public class LeafTableModel extends BaseTableModel
{
private static final long serialVersionUID = 1L;
private OrderedMap<Object> map = new OrderedMap<Object>();
public LeafTableModel(String n[])
{
super( n, null );
setChangeable( false );
}
public void clearAll()
{
int i = map.rows();
if( i > 0 )
{
map.clear();
fireTableRowsDeleted( 0, i - 1 );
}
}
@Override
public int innerGetRowCount()
{
return map == null ? 0 : map.rows();
}
@Override
public Object innerGetValueAt( int row, int col )
{
return map.getValueAt( row, col );
}
@Override
public void deleteRow( int row )
{
map.deleteRow( row );
}
public Object getKey( int row )
{
Object result = null;
if( row < map.rows() )
{
result = map.getKeyForRow( row );
}
return result;
}
public void setValues( Collection<? extends Object> v )
{
Iterator<? extends Object> iterator = v.iterator();
while( iterator.hasNext() )
{
Object value = iterator.next();
map.putLast( value, value.toString() );
}
fireTableDataChanged();
}
public void setValues( OrderedMap<Object> map )
{
this.map = map;
fireTableDataChanged();
}
@Override
public void appendEmptyRow()
{
map.putLast( map.rows(), null );
}
@Override
public void innerSetValueAt( Object obj, int row, int col )
{
if( isCellEditable( row, col ) && map.getValueAt( row, col ) != null )
{
map.setValueAt( row, col, obj );
}
}
@Override
public boolean isRowEmpty( int row )
{
List<Object> line = map.getRow( row );
return line != null && line.size() > 0;
}
@Override
public boolean innerIsCellEditable( int row, int col )
{
return false;
}
public void printContents()
{
for( int r = 0; r < getRowCount(); r++ )
{
for( int c = 0; c < getColumnCount(); c++ )
{
Object val = getValueAt( r, c );
if( val != null )
{
System.out.print( val.toString() + "\t" );
}
}
System.out.println( "" );
}
}
// public void insertRowAt( Object rowObj, int row )
// {
// values.add( row, rowObj );
// fireTableDataChanged();
// }
//
// public void removeRowAt( int row )
// {
// values.remove( row );
// fireTableDataChanged();
// }
//
// public Object getRowAt( int row )
// {
// return values.elementAt( row );
// }
// public void swapRows( int row1, int row2 )
// {
// if( row1 == row2 || row1 < 0 || row2 < 0 || row1 >= getRowCount() || row2
// >= getRowCount() )
// {
// return;
// }
// // Collections.swap( values, row1, row2 );
// Object row1Data = getRowAt( row1 );
// Object row2Data = getRowAt( row2 );
// if( row1 < row2 )
// {
// removeRowAt( row2 );
// removeRowAt( row1 );
// insertRowAt( row2Data, row1 );
// insertRowAt( row1Data, row2 );
// }
// else
// {
// removeRowAt( row1 );
// removeRowAt( row2 );
// insertRowAt( row1Data, row2 );
// insertRowAt( row2Data, row1 );
// }
// }
}

@ -1,5 +1,6 @@
package leaf;
import static leaf.LeafLogic.ACTION_CANCEL;
import static leaf.LeafLogic.ACTION_STARTUP;
import java.awt.Cursor;
@ -61,7 +62,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
*
* @return
*/
String [] onSelect();
String[] onSelect();
/**
* Array of actions to execute when a change is listened in this
@ -69,7 +70,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
*
* @return
*/
String [] onChange();
String[] onChange();
}
@ -86,7 +87,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
/**
* Actions that use this field
*/
String [] useWith();
String[] useWith();
}
/**
@ -131,12 +132,19 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
* Meta-info
*/
private Map<Object, Annotation> mapAnnotationByObject = new HashMap<Object, Annotation>();
/**
* Run later actions
* Run later actions
*/
private Queue<String> listRunLater = new LinkedList<String>();
/**
* Creates a new LeafWindow binded with given 'logicController'
*
* @param logicController
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public LeafWindow(LeafLogic logicController) throws IllegalArgumentException, IllegalAccessException
{
super();
@ -147,6 +155,109 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
}
}
@Override
public void open()
{
setVisible( true );
}
public void close()
{
SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
setVisible( false );
dispose();
}
} );
}
@Override
public boolean closeIfPossible()
{
close();
return true;
}
@Override
public void refresh()
{
}
/**
* Aborts current action. Aborts pending actions as well if 'all' is true
*
* @param all
*/
public void abortAction( boolean all )
{
runGivenAction( ACTION_CANCEL, null );
throw new LeafRuntimeException( all );
}
protected boolean runAction( String actionName )
{
return runAction( actionName, null );
}
/**
* Returns false if an error occurred
*
* @param actionName
* @param argument
* @return
*/
protected boolean runAction( String actionName, Object argument )
{
boolean ok = true;
if( argument == null )
{
Field field = mapLeafObjectByActionName.get( actionName );
if(field != null)
{
Object instance = mapInstanceByField.get( field );
if( instance != null)
{
try
{
argument = field.get( instance );
} catch( IllegalArgumentException e )
{
e.printStackTrace(System.out);
} catch( IllegalAccessException e )
{
e.printStackTrace( System.out);
}
}
}
}
try
{
runGivenAction( actionName, argument );
} catch( LeafRuntimeException leafRuntimeException )
{
ok = !leafRuntimeException.isAbort();
}
if( ok )
{
runPendingActions();
}
else
{
listRunLater.clear();
}
return ok;
}
public void runActionLater( String action )
{
if( action != null && mapActionByName.containsKey( action ) )
{
listRunLater.add( action );
}
}
public void completeSetup()
{
try
@ -216,7 +327,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
// valid action
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
mapWindowOnChangeFieldByActionName.get( onChange ).add( field.get( instance ) );
if(!mapInstanceByField.containsKey( field ))
if( !mapInstanceByField.containsKey( field ) )
{
addListenerForField( componentBehaviour, field, instance );
mapInstanceByField.put( field, instance );
@ -224,7 +335,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
}
}
}
String[] allSelect = componentBehaviour.onSelect();
if( allSelect != null )
{
@ -235,7 +346,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
// valid action
mapAnnotationByObject.put( field.get( instance ), componentBehaviour );
mapWindowOnSelectFieldByActionName.get( onSelect ).add( field.get( instance ) );
if(!mapInstanceByField.containsKey( field ))
if( !mapInstanceByField.containsKey( field ) )
{
addListenerForField( componentBehaviour, field, instance );
mapInstanceByField.put( field, instance );
@ -248,10 +359,10 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
LeafObject leafObject = field.getAnnotation( LeafObject.class );
if( leafObject != null )
{
String [] useWith = leafObject.useWith();
String[] useWith = leafObject.useWith();
if( useWith != null )
{
for(String current : useWith )
for( String current : useWith )
{
if( mapActionByName.containsKey( current ) )
{
@ -300,14 +411,14 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
LeafUIActionBinding actionBinding = method.getAnnotation( LeafUIActionBinding.class );
if( actionBinding != null )
{
String [] actions = actionBinding.action();
for(String actionName : actions)
String[] actions = actionBinding.action();
for( String actionName : actions )
{
if( mapActionByName.containsKey( actionName ) )
{
// valid action
mapWindowMethodsByActionName.get( actionName ).add( method );
mapAnnotationByObject.put( method, actionBinding );
mapInstanceByMethod.put( method, instance );
}
@ -390,42 +501,23 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
return result;
}
public void runAction( String actionName )
{
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)
while( listRunLater.size() > 0 )
{
runAction( listRunLater.poll() );
}
}
/**
* Executes given action
*/
private void runGivenAction( String actionName, Object argument )
{
System.out.println( "Running: " + actionName );
try{
this.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ));
try
{
this.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
if( actionName != null && mapActionByName.containsKey( actionName ) )
{
Action action = mapActionByName.get( actionName );
@ -449,13 +541,13 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
}
}
}
}finally
} finally
{
this.setCursor( Cursor.getDefaultCursor());
this.setCursor( Cursor.getDefaultCursor() );
}
}
private Object runLogicMethod( Method logicMethod, Object argument )
private Object runLogicMethod( Method logicMethod, Object argument ) throws LeafRuntimeException
{
Object result = null;
try
@ -473,18 +565,27 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
}
} catch( IllegalArgumentException e )
{
System.out.println("Error in: " + logicMethod.getName() );
System.out.println("Got: " + argument + " expected: " + (logicMethod.getParameterTypes().length > 0 ? logicMethod.getParameterTypes()[0].getCanonicalName() : "(nothing)"));
e.printStackTrace( System.out );
} catch( IllegalAccessException e )
{
e.printStackTrace( System.out );
} catch( InvocationTargetException e )
{
e.printStackTrace( System.out );
if( e.getCause() instanceof LeafRuntimeException )
{
throw (LeafRuntimeException) e.getCause();
}
else
{
e.printStackTrace( System.out );
}
}
return result;
}
private Object runWindowMethod( Method windowMethod, Object argument )
private Object runWindowMethod( Method windowMethod, Object argument ) throws LeafRuntimeException
{
Object result = null;
try
@ -502,45 +603,24 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
}
} catch( IllegalArgumentException e )
{
System.out.println("Error in: " + windowMethod.getName() );
System.out.println("Got: " + argument + " expected: " + (windowMethod.getParameterTypes().length > 0 ? windowMethod.getParameterTypes()[0].getCanonicalName() : "(nothing)"));
e.printStackTrace( System.out );
} catch( IllegalAccessException e )
{
e.printStackTrace( System.out );
} catch( InvocationTargetException e )
{
e.printStackTrace( System.out );
}
return result;
}
@Override
public void open()
{
setVisible( true );
}
public void close()
{
SwingUtilities.invokeLater( new Runnable()
{
public void run()
if( e.getCause() instanceof LeafRuntimeException )
{
setVisible( false );
dispose();
throw (LeafRuntimeException) e.getCause();
}
} );
}
@Override
public boolean closeIfPossible()
{
close();
return true;
}
@Override
public void refresh()
{
else
{
e.printStackTrace( System.out );
}
}
return result;
}
private void addListenerForField( ActionActivation annotation, Field field, Object instance )
@ -592,6 +672,10 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
{
return ((ColumnizedMappable) ((VectorTableModel) model).getRowAt( index )).getID();
}
else if( model instanceof LeafTableModel )
{
return ((LeafTableModel) model).getKey( index );
}
}
}
}
@ -601,11 +685,12 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
private List<String> getActionListSelectionEvent( ListSelectionEvent event )
{
List<String> result = new ArrayList<String>();
if( event.getSource() instanceof DefaultListSelectionModel)
if( event.getSource() instanceof DefaultListSelectionModel )
{
DefaultListSelectionModel model = (DefaultListSelectionModel) event.getSource();
BaseTable table = null;
for(List<Object> allComponents : mapWindowOnSelectFieldByActionName.values()){
for( List<Object> allComponents : mapWindowOnSelectFieldByActionName.values() )
{
// for each registered table
for( Object component : allComponents )
{
@ -613,20 +698,20 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
{
table = (BaseTable) component;
}
if( table != null)
if( table != null )
{
break;
}
}
if( table != null)
if( table != null )
{
break;
}
}
Annotation an = mapAnnotationByObject.get( table );
if(an != null && an instanceof ActionActivation)
if( an != null && an instanceof ActionActivation )
{
String [] actions = ((ActionActivation) an).onSelect();
String[] actions = ((ActionActivation) an).onSelect();
for( String actionName : actions )
{
result.add( actionName );
@ -658,9 +743,9 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
{
List<String> result = new ArrayList<String>();
Annotation an = mapAnnotationByObject.get( event.getSource() );
if(an != null && an instanceof ActionActivation)
if( an != null && an instanceof ActionActivation )
{
String [] actions = ((ActionActivation) an).onSelect();
String[] actions = ((ActionActivation) an).onSelect();
for( String actionName : actions )
{
result.add( actionName );
@ -673,9 +758,9 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
{
List<String> result = new ArrayList<String>();
Annotation an = mapAnnotationByObject.get( event.getSource() );
if(an != null && an instanceof ActionActivation)
if( an != null && an instanceof ActionActivation )
{
String [] actions = ((ActionActivation) an).onSelect();
String[] actions = ((ActionActivation) an).onSelect();
for( String actionName : actions )
{
result.add( actionName );
@ -683,21 +768,20 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
}
return result;
}
private List<String> getActionsForPropertyChangeEvent( PropertyChangeEvent evt )
{
List<String> result = new ArrayList<String>();
Annotation an = mapAnnotationByObject.get( evt.getSource() );
if(an != null)
if( an != null )
{
if(an instanceof ActionActivation)
if( an instanceof ActionActivation )
{
if(evt.getSource() instanceof LeafInputField)
if( evt.getSource() instanceof LeafInputField )
{
if( LeafInputField.PROPERTY_CHANGED_CONSTANT.equals( evt.getPropertyName()))
if( LeafInputField.PROPERTY_CHANGED_CONSTANT.equals( evt.getPropertyName() ) )
{
String [] actions = ((ActionActivation) an).onChange();
String[] actions = ((ActionActivation) an).onChange();
for( String actionName : actions )
{
result.add( actionName );
@ -712,11 +796,14 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
@Override
public void valueChanged( TreeSelectionEvent event )
{
List<String> actions= getActionTreeSelectionEvent( event );
List<String> actions = getActionTreeSelectionEvent( event );
for( String action : actions )
{
Object argument = getArgumentTreeSelectionEvent( action, event );
runAction( action, argument );
if( !runAction( action, argument ) )
{
break;
}
}
}
@ -731,8 +818,11 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
List<String> actionNames = getActionListSelectionEvent( event );
for( String action : actionNames )
{
Object argument = getArgumentListSelectionEvent(action, event);
runAction( action, argument );
Object argument = getArgumentListSelectionEvent( action, event );
if( !runAction( action, argument ) )
{
break;
}
}
}
}
@ -740,10 +830,14 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
@Override
public void actionPerformed( ActionEvent event )
{
List<String> actionName = getActionActionEvent( event );
for( String action : actionName )
List<String> actionNames = getActionActionEvent( event );
if( actionNames.size() > 0 )
{
runAction( action, null );
for( int i = 1; i < actionNames.size(); ++i )
{
runActionLater( actionNames.get( i ) );
}
runAction( actionNames.get( 0 ) );
}
}
@ -751,11 +845,14 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
public void propertyChange( PropertyChangeEvent evt )
{
List<String> actionNames = getActionsForPropertyChangeEvent( evt );
for( String action : actionNames )
if( actionNames.size() > 0 )
{
runActionLater( action);
for( int i = 1; i < actionNames.size(); ++i )
{
runActionLater( actionNames.get( i ) );
}
runAction( actionNames.get( 0 ) );
}
}
}

@ -10,11 +10,15 @@ import java.util.Locale;
import org.apache.cayenne.CayenneDataObject;
import org.apache.cayenne.PersistenceState;
import siprp.database.cayenne.providers.MedicinaDAO;
import siprp.medicina.MedicinaConstants;
public class BaseObject extends CayenneDataObject
{
private static final long serialVersionUID = 1L;
protected static MedicinaDAO medicinaProvider = new MedicinaDAO();
protected static final DateFormat sdf = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
protected static final String isNewMessage = "Em Edi"+ccedil+atilde+"o";

@ -1,9 +1,53 @@
package siprp.database.cayenne.objects;
import com.evolute.utils.strings.UnicodeChecker;
import siprp.database.cayenne.objects.auto._Empresas;
public class Empresas extends _Empresas {
private static final long serialVersionUID = 1L;
private String name = null;
private String convertedName = null;
@Override
public String getDesignacaoSocial()
{
String currentName = super.getDesignacaoSocial();
if( name == null || !name.equals( currentName ))
{
name = currentName;
convertedName = null;
}
return convertName();
}
@Override
public void setDesignacaoSocial( String nome )
{
super.setDesignacaoSocial( UnicodeChecker.parseToUnicode( name ) );
getDesignacaoSocial();
}
private String convertName()
{
if( name == null )
{
convertedName = null;
}
else
{
convertedName = UnicodeChecker.parseFromUnicode( name );
}
return convertedName;
}
@Override
public String toString()
{
return getDesignacaoSocial();
}
}

@ -1,9 +1,54 @@
package siprp.database.cayenne.objects;
import com.evolute.utils.strings.UnicodeChecker;
import siprp.database.cayenne.objects.auto._Estabelecimentos;
public class Estabelecimentos extends _Estabelecimentos {
private static final long serialVersionUID = 1L;
private String name = null;
private String convertedName = null;
@Override
public String getNome()
{
String currentName = super.getNome();
if( name == null || !name.equals( currentName ))
{
name = currentName;
convertedName = null;
}
return convertName();
}
@Override
public void setNome( String nome )
{
super.setNome( UnicodeChecker.parseToUnicode( name ) );
getNome();
}
private String convertName()
{
if( name == null )
{
convertedName = null;
}
else
{
convertedName = UnicodeChecker.parseFromUnicode( name );
}
return convertedName;
}
@Override
public String toString()
{
return getNome();
}
}

@ -1,5 +1,7 @@
package siprp.database.cayenne.objects;
import java.util.List;
import siprp.database.cayenne.objects.auto._Prestadores;
import com.evolute.utils.strings.UnicodeChecker;
@ -12,6 +14,12 @@ public class Prestadores extends _Prestadores {
private String convertedName = null;
public static final Prestadores prestadorNulo = new Prestadores();
static {
prestadorNulo.setNome( "SIPRP" );
}
@Override
public String getNome()
{
@ -27,7 +35,7 @@ public class Prestadores extends _Prestadores {
@Override
public void setNome( String nome )
{
super.setNome( UnicodeChecker.parseToUnicode( name ) );
super.setNome( UnicodeChecker.parseToUnicode( nome ) );
getNome();
}
@ -43,7 +51,24 @@ public class Prestadores extends _Prestadores {
}
return convertedName;
}
// public static Prestadores getDefaultPrestador()
// {
// return medicinaProvider.getDefaultPrestador();
// }
public static List<Prestadores> getAllPrestadores()
{
List<Prestadores> result = medicinaProvider.getAllPrestadores();
result.add( 0, prestadorNulo);
return result;
}
@Override
public String toString()
{
return getNome();
}
}

@ -62,7 +62,7 @@ public class Trabalhadores extends _Trabalhadores
@Override
public String toString()
{
return getNomePlain();
return getNome();
}
}

@ -26,6 +26,7 @@ public abstract class _Prestadores extends siprp.database.cayenne.objects.BaseOb
public static final String TO_CONTACTOS_PROPERTY = "toContactos";
public static final String TRABALHADORES_CONSULTAS_ARRAY_PROPERTY = "trabalhadoresConsultasArray";
public static final String TRABALHADORES_CONSULTAS_DATAS_ARRAY_PROPERTY = "trabalhadoresConsultasDatasArray";
public static final String TRABALHADORES_ECD_ARRAY_PROPERTY = "trabalhadoresEcdArray";
public static final String TRABALHADORES_ECDS_DATAS_ARRAY_PROPERTY = "trabalhadoresEcdsDatasArray";
public static final String ID_PK_COLUMN = "id";
@ -204,6 +205,17 @@ public abstract class _Prestadores extends siprp.database.cayenne.objects.BaseOb
}
public void addToTrabalhadoresEcdArray(siprp.database.cayenne.objects.TrabalhadoresEcd obj) {
addToManyTarget("trabalhadoresEcdArray", obj, true);
}
public void removeFromTrabalhadoresEcdArray(siprp.database.cayenne.objects.TrabalhadoresEcd obj) {
removeToManyTarget("trabalhadoresEcdArray", obj, true);
}
public java.util.List getTrabalhadoresEcdArray() {
return (java.util.List)readProperty("trabalhadoresEcdArray");
}
public void addToTrabalhadoresEcdsDatasArray(siprp.database.cayenne.objects.TrabalhadoresEcdsDatas obj) {
addToManyTarget("trabalhadoresEcdsDatasArray", obj, true);
}

@ -9,6 +9,7 @@ public abstract class _TrabalhadoresEcd extends siprp.database.cayenne.objects.B
public static final String ENVIADO_PROPERTY = "enviado";
public static final String ESTADO_PROPERTY = "estado";
public static final String TO_ANALISADOR_PROPERTY = "toAnalisador";
public static final String TO_ECD_OFICIAL_PROPERTY = "toEcdOficial";
public static final String TO_PRT_TIPOS_ELEMENTOS_PROTOCOLO_PROPERTY = "toPrtTiposElementosProtocolo";
public static final String TO_TRABALHADORES_ECDS_DATAS_PROPERTY = "toTrabalhadoresEcdsDatas";
@ -31,6 +32,15 @@ public abstract class _TrabalhadoresEcd extends siprp.database.cayenne.objects.B
}
public void setToAnalisador(siprp.database.cayenne.objects.Prestadores toAnalisador) {
setToOneTarget("toAnalisador", toAnalisador, true);
}
public siprp.database.cayenne.objects.Prestadores getToAnalisador() {
return (siprp.database.cayenne.objects.Prestadores)readProperty("toAnalisador");
}
public void setToEcdOficial(siprp.database.cayenne.objects.EcdOficial toEcdOficial) {
setToOneTarget("toEcdOficial", toEcdOficial, true);
}

@ -1,6 +1,7 @@
package siprp.database.cayenne.providers;
import org.apache.cayenne.access.DataContext;
import org.apache.cayenne.conf.Configuration;
public class MainDAO
{
@ -10,14 +11,12 @@ public class MainDAO
{
if( context == null )
{
// DefaultConfiguration conf = new DefaultConfiguration();
// conf.addClassPath("");
// conf.getDomain().getProperties();
// Configuration.initializeSharedConfiguration();
// Configuration.getSharedConfiguration().getDomain().getNode( "SIPRPNode" ).getDataSource();
context = DataContext.createDataContext();
}
}
/*
* String fileName = "/some/path/to/my-cayenne.xml";
FileConfiguration conf = new FileConfiguration(new File(fileName));
Configuration.initializeSharedConfiguration(conf);
*/
}

@ -1,7 +1,6 @@
package siprp.database.cayenne.providers;
import java.util.List;
import java.util.Vector;
import org.apache.cayenne.DataObjectUtils;
import org.apache.cayenne.PersistenceState;
@ -10,67 +9,48 @@ import org.apache.cayenne.query.SelectQuery;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.Prestadores;
import siprp.database.cayenne.objects.Trabalhadores;
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
import siprp.medicina.processo.ProcessoConstants;
import com.evolute.utils.tables.ColumnizedMappable;
public class MedicinaDAO extends MainDAO
{
private static final String defaultPrestadorName = "SIPRP";
private Prestadores defaultPrestador = null;
public Trabalhadores getTrabalhadorByID( Integer id )
{
return (Trabalhadores) DataObjectUtils.objectForPK( context, Trabalhadores.class, id );
}
public Vector<ColumnizedMappable> getAllEmpresas()
public List<Empresas> getAllEmpresas()
{
Vector<ColumnizedMappable> result = new Vector<ColumnizedMappable>();
SelectQuery query = new SelectQuery( Empresas.class );
query.andQualifier( ExpressionFactory.noMatchExp( Empresas.INACTIVO_PROPERTY, "y" ) );
query.addOrdering( Empresas.DESIGNACAO_SOCIAL_PLAIN_PROPERTY, true );
List<Empresas> allEmpresas = context.performQuery( query );
for( Empresas currentEmpresa : allEmpresas )
{
Integer id = currentEmpresa.getId();
String designacao = currentEmpresa.getDesignacaoSocialPlain().toUpperCase();
result.add( new ColumnizedMappable( id, designacao ) );
}
return result;
return allEmpresas;
}
public Vector<ColumnizedMappable> getEstabelecimentosForEmpresa( Integer empresaID )
{
Vector<ColumnizedMappable> result = new Vector<ColumnizedMappable>();
SelectQuery query = new SelectQuery( Estabelecimentos.class, ExpressionFactory.matchExp( Estabelecimentos.TO_EMPRESAS_PROPERTY, empresaID ) );
query.andQualifier( ExpressionFactory.noMatchExp( Estabelecimentos.INACTIVO_PROPERTY, "y" ) );
query.addOrdering( Estabelecimentos.NOME_PLAIN_PROPERTY, true );
List<Estabelecimentos> allEstabelecimentos = context.performQuery( query );
for( Estabelecimentos currentEstabelecimento : allEstabelecimentos )
{
Integer id = currentEstabelecimento.getId();
String designacao = currentEstabelecimento.getNomePlain().toUpperCase();
result.add( new ColumnizedMappable( id, designacao ) );
}
return result;
}
public Vector<ColumnizedMappable> getTrabalhadoresForEstabelecimento( Integer estabelecimentoID )
public List<Prestadores> getAllPrestadores()
{
Vector<ColumnizedMappable> result = new Vector<ColumnizedMappable>();
SelectQuery query = new SelectQuery( Trabalhadores.class, ExpressionFactory.matchExp( Trabalhadores.TO_ESTABELECIMENTOS_PROPERTY, estabelecimentoID ) );
query.andQualifier( ExpressionFactory.noMatchExp( Trabalhadores.INACTIVO_PROPERTY, "y" ) );
query.addOrdering( Trabalhadores.NOME_PLAIN_PROPERTY, true );
List<Trabalhadores> allTrabalhadores = context.performQuery( query );
for( Trabalhadores currentTrabalhador : allTrabalhadores )
SelectQuery query = new SelectQuery( Prestadores.class );
query.andQualifier( ExpressionFactory.matchExp( Prestadores.ACTIVO_PROPERTY, "y" ) );
query.addOrdering( Prestadores.NOME_PROPERTY, true );
List<Prestadores> allPrestadores = context.performQuery( query );
if( defaultPrestador == null )
{
Integer id = currentTrabalhador.getId();
String designacao = currentTrabalhador.getNome();
result.add( new ColumnizedMappable( id, designacao ) );
for(Prestadores current : allPrestadores)
{
if(defaultPrestadorName.equals( current.getNomePlain() ))
{
defaultPrestador = current;
break;
}
}
}
return result;
return allPrestadores;
}
public BaseObject saveObject( BaseObject object )
@ -85,6 +65,13 @@ public class MedicinaDAO extends MainDAO
}
return object;
}
public void rollback()
{
context.rollbackChanges();
context.unregisterObjects( context.uncommittedObjects() );
context.deleteObjects( context.newObjects() );
}
public void fecharProcesso( TrabalhadoresProcesso currentProcesso )
{
@ -92,4 +79,13 @@ public class MedicinaDAO extends MainDAO
context.commitChanges();
}
public Prestadores getDefaultPrestador()
{
if(defaultPrestador == null)
{
getAllPrestadores();
}
return defaultPrestador;
}
}

@ -10,6 +10,8 @@ import leaf.LeafLogic;
import leaf.LeafWindow.LeafObject;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.Prestadores;
import siprp.database.cayenne.objects.Trabalhadores;
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
@ -174,8 +176,13 @@ public class MedicinaProcessoLogic extends LeafLogic
public static final String ANULAR_EXAME_MARCACAO = "ANULAR_EXAME_MARCACAO";
private MedicinaDAO provider = null;
public Empresas currentEmpresa = null;
public Estabelecimentos currentEstabelecimento = null;
private Trabalhadores currentTrabalhador = null;
@LeafObject (useWith=LOAD_TRABALHADOR)
public Trabalhadores currentTrabalhador = null;
@LeafObject(useWith = SAVE_PROCESSO)
public TrabalhadoresProcesso currentProcesso = null;
@ -221,7 +228,7 @@ public class MedicinaProcessoLogic extends LeafLogic
@LeafLogicActionBinding(actions = {
ACTION_STARTUP
})
public Vector<ColumnizedMappable> getAllEmpresas()
public List<Empresas> getAllEmpresas()
{
return provider.getAllEmpresas();
}
@ -229,32 +236,33 @@ public class MedicinaProcessoLogic extends LeafLogic
@LeafLogicActionBinding(actions = {
SELECT_EMPRESA
})
public Vector<ColumnizedMappable> getEstabelecimentosForEmpresa( Integer empresaID )
public Empresas setEmpresa(Empresas empresa)
{
return provider.getEstabelecimentosForEmpresa( empresaID );
currentEmpresa = empresa;
return currentEmpresa;
}
@LeafLogicActionBinding(actions = {
SELECT_ESTABELECIMENTO
})
public Vector<ColumnizedMappable> getTrabalhadoresForEstabelecimento( Integer estabelecimentoID )
public Estabelecimentos setEstabelecimento( Estabelecimentos estabelecimento )
{
return provider.getTrabalhadoresForEstabelecimento( estabelecimentoID );
currentEstabelecimento = estabelecimento;
return currentEstabelecimento;
}
@LeafLogicActionBinding(actions = {
LOAD_TRABALHADOR
})
public Trabalhadores getDadosTrabalhador( Integer id )
public Trabalhadores getDadosTrabalhador( Trabalhadores trabalhador )
{
Trabalhadores result = null;
clearAll();
if( id != null )
{
result = provider.getTrabalhadorByID( id );
}
currentTrabalhador = result;
return result;
// Trabalhadores result = null;
// if( id != null )
// {
// result = provider.getTrabalhadorByID( id );
// }
currentTrabalhador = trabalhador;
return currentTrabalhador;
}
@LeafLogicActionBinding(actions = FECHAR_PROCESSO)
@ -542,7 +550,15 @@ public class MedicinaProcessoLogic extends LeafLogic
public void saveObject( BaseObject object )
{
provider.saveObject( object );
runAction( REFRESH );
runActionLater( REFRESH );
}
@LeafLogicActionBinding(actions=ACTION_CANCEL)
public void abortAction()
{
provider.rollback();
runAction( LOAD_TRABALHADOR );
runAction( SELECT_TRABALHADOR );
}
private Prestadores getPrestador(boolean consulta)
@ -559,19 +575,4 @@ public class MedicinaProcessoLogic extends LeafLogic
return getPrestador( false );
}
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;
}
}

@ -106,7 +106,7 @@ public class MedicinaProcessoWindow extends LeafWindow
OrderedMap<PrtGruposProtocolo> grupos = new OrderedMap<PrtGruposProtocolo>();
for(int row = 0; row < allGrupos.rows(); ++row)
{
List<Object> grupo = allGrupos.getValuesAt( row );
List<Object> grupo = allGrupos.getRow( row );
if( grupo != null && grupo.size() > 1)
{
String estado = grupo.get( 1 ).toString();

@ -1,18 +1,13 @@
package siprp.medicina.processo.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
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 siprp.database.cayenne.objects.PrtGruposProtocolo;
import com.evolute.utils.sql.expression.Or;
public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
{
private static final long serialVersionUID = 1L;
@ -25,7 +20,17 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
{
}
public List<Object> getValuesAt( int row )
public OrderedMap(Collection<KeyClass> allPrestadores)
{
Iterator<KeyClass> iterator = allPrestadores.iterator();
while(iterator.hasNext())
{
KeyClass value = iterator.next();
this.putLast( value, value );
}
}
public List<Object> getRow( int row )
{
return map.get( order.get( row ) );
}
@ -45,14 +50,15 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
for( KeyClass key : map.keySet() )
{
List<Object> values = map.get( key );
if( value.equals( values ))
if( value.equals( values ) )
{
return key;
}else
}
else
{
for(Object currentValue : values)
for( Object currentValue : values )
{
if(currentValue.equals(value))
if( currentValue.equals( value ) )
{
return key;
}
@ -76,18 +82,18 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
}
return result;
}
public List<Object> getColumn(int i)
public List<Object> getColumn( int i )
{
List<Object> result = new ArrayList<Object>();
if(order != null && order.size() > 0)
if( order != null && order.size() > 0 )
{
for(KeyClass key : order)
for( KeyClass key : order )
{
List<Object> row = map.get( key );
if(row != null && row.size() > 0)
if( row != null && row.size() > 0 )
{
result.add(row.get( 0 ));
result.add( row.get( 0 ) );
}
else
{
@ -113,9 +119,18 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
return map.containsKey( key );
}
public Object getValueAt( int column, int row )
public Object getValueAt( int row, int column )
{
return this.getValuesAt( row ).get( column );
Object result = null;
if( row < order.size() )
{
List<Object> line = map.get( order.get( row ));
if( column < line.size())
{
result = line.get( column );
}
}
return result;
}
public void putLast( KeyClass key, Object value )
@ -139,32 +154,32 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
order.remove( key );
return map.remove( key );
}
/**
* Orders by first column (rows compared as strings)
*/
public void order()
{
if(order != null && order.size() > 0)
if( order != null && order.size() > 0 )
{
HashMap<Object, KeyClass> keyForObject = new HashMap<Object, KeyClass>();
List<String> sortedList = new ArrayList<String>();
for(KeyClass key : order)
for( KeyClass key : order )
{
List<Object> row = map.get( key );
Object value = null;
if( row != null && row.size() > 0)
if( row != null && row.size() > 0 )
{
value = row.get( 0 );
keyForObject.put( value.toString() , key );
keyForObject.put( value.toString(), key );
sortedList.add( value.toString() );
}
}
if(sortedList.size() == order.size())
if( sortedList.size() == order.size() )
{
Collections.sort( sortedList );
Vector<KeyClass> newOrder = new Vector<KeyClass>();
for(String value : sortedList)
for( String value : sortedList )
{
newOrder.add( keyForObject.get( value ) );
}
@ -175,11 +190,68 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
public void addRow( KeyClass key, List<Object> grupo )
{
if(key != null && grupo != null)
if( key != null && grupo != null )
{
order.add( key );
map.put( key, grupo );
}
}
public void clear()
{
order.clear();
map.clear();
}
public void deleteRow( int row )
{
if( row < order.size() )
{
KeyClass key = order.get( row );
order.remove( row );
map.remove( key );
}
}
public KeyClass getKeyForRow( int row )
{
KeyClass result = null;
if( row < order.size() )
{
result = order.get( row );
}
return result;
}
public void setValueAt( int row, int col, Object obj )
{
if( row < order.size() )
{
List<Object> line = map.get( order.get( row ) );
if( col < line.size() )
{
line.add( col, obj );
}
}
}
public Object getFirstValue( KeyClass key )
{
return getValue( key, 0 );
}
public Object getValue( KeyClass key, int i )
{
Object result = null;
if(key != null && order.contains( key))
{
List<Object> row = map.get( key );
if(row != null && row.size() > i)
{
result = row.get( i );
}
}
return result;
}
}

@ -56,12 +56,14 @@ import leaf.LeafWindow;
import leaf.LeafLogic.LeafUIActionBinding;
import leaf.LeafWindow.ActionActivation;
import siprp.database.cayenne.objects.Prestadores;
import siprp.database.cayenne.objects.PrtGruposProtocolo;
import siprp.database.cayenne.objects.Trabalhadores;
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes;
import siprp.database.cayenne.objects.TrabalhadoresEcd;
import siprp.database.cayenne.objects.TrabalhadoresEcds;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails;
@ -151,7 +153,8 @@ public class ProcessoDadosPanel extends JPanel
public final LeafInputField<HashMap<Integer, String>> inputConsultaMarcacaoEstado = new LeafInputField<HashMap<Integer, String>>();
public final LeafInputField<Date> inputConsultaMarcacaoData = new LeafInputField<Date>();
public final LeafInputField<String> inputConsultaMarcacaoPrestador = new LeafInputField<String>();
@ActionActivation(onSelect = "", onChange = SAVE_CONSULTA_MARCACAO)
public final LeafInputField<OrderedMap<Prestadores>> inputConsultaMarcacaoPrestador = new LeafInputField<OrderedMap<Prestadores>>();
// email marcacao consulta
private final JLabel labelConsultaMarcacaoEmailData = new JLabel( "Data" );
@ -180,13 +183,15 @@ public class ProcessoDadosPanel extends JPanel
private final JLabel labelExameMarcacaoData = new JLabel( "Data" );
private final JLabel labelExameMarcacaoGruposEcds = new JLabel( "ECDs" );
private final JLabel labelExameMarcacaoPrestador = new JLabel( "Prestador" );
private final JLabel labelExameMarcacaoAnalisador = new JLabel( "Analisador" );
private final JLabel labelExameMarcacaoAnalisador = new JLabel( "Analisadores" );
public final LeafInputField<HashMap<Integer, String>> inputExameMarcacaoEstado = new LeafInputField<HashMap<Integer, String>>();
public final LeafInputField<Date> inputExameMarcacaoData = new LeafInputField<Date>();
public final LeafInputField<OrderedMap<PrtGruposProtocolo>> inputExameMarcacaoGruposEcds = new LeafInputField<OrderedMap<PrtGruposProtocolo>>();
public final LeafInputField<String> inputExameMarcacaoPrestador = new LeafInputField<String>();
public final LeafInputField<String> inputExameMarcacaoAnalisador = new LeafInputField<String>();
@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO)
public final LeafInputField<OrderedMap<Prestadores>> inputExameMarcacaoPrestador = new LeafInputField<OrderedMap<Prestadores>>();
@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO)
public final LeafInputField<OrderedMap<PrtGruposProtocolo>> inputExameMarcacaoAnalisador = new LeafInputField<OrderedMap<PrtGruposProtocolo>>();
// email marcacao exame
private final JLabel labelExameMarcacaoEmailData = new JLabel( "Data" );
@ -198,6 +203,7 @@ public class ProcessoDadosPanel extends JPanel
public final LeafInputField<String> inputExameMarcacaoEmailBody = new LeafInputField<String>();
// observacao marcacao exame
@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO_OBSERVACOES)
public final LeafInputField<String> inputExameMarcacaoObsMensagem = new LeafInputField<String>();
public ProcessoDadosPanel(LeafWindow parentWindow)
@ -289,8 +295,8 @@ public class ProcessoDadosPanel extends JPanel
{
inputConsultaEstado.setObject( consulta.getConsultaEstados(), consulta.getEstado() );
inputConsultaData.setObject( consulta.getData() == null ? new Date( 0 ) : consulta.getData() );
inputConsultaPrestador.setObject( (consulta.getToPrestadores() == null || consulta.getToPrestadores().getNome() == null )? " " : consulta.getToPrestadores().getNome() );
inputConsultaPrestador.setObject( (consulta.getToPrestadores() == null || consulta.getToPrestadores().getNome() == null) ? " " : consulta.getToPrestadores().getNome() );
cardLayout.show( this, PANEL_CONSULTA_NAME );
}
@ -307,7 +313,12 @@ public class ProcessoDadosPanel extends JPanel
{
inputConsultaMarcacaoData.setObject( marcacao.getData() );
inputConsultaMarcacaoEstado.setObject( marcacao.getConsultaEstados(), marcacao.getEstado() );
inputConsultaMarcacaoPrestador.setObject( (marcacao.getToPrestadores() == null || marcacao.getToPrestadores().getNome() == null )? " " : marcacao.getToPrestadores().getNome() );
inputConsultaMarcacaoPrestador.setEditable( true );
Prestadores prestador = marcacao.getToPrestadores();
List<Prestadores> allPrestadores = Prestadores.getAllPrestadores();
inputConsultaMarcacaoPrestador.setObject( new OrderedMap<Prestadores>( allPrestadores ), prestador == null ? Prestadores.prestadorNulo : prestador );
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_NAME );
}
else
@ -375,10 +386,55 @@ public class ProcessoDadosPanel extends JPanel
OrderedMap<PrtGruposProtocolo> grupos = exameMarcacao.getStatesForeGruposExames();
inputExameMarcacaoGruposEcds.setCollapseOptions( false );
inputExameMarcacaoGruposEcds.setObject( grupos, grupos.getFirst() );
inputExameMarcacaoPrestador.setObject( (exameMarcacao.getToPrestadores() == null || exameMarcacao.getToPrestadores().getNome() == null )? " " : exameMarcacao.getToPrestadores().getNome() );
inputExameMarcacaoAnalisador.setObject( (exameMarcacao.getToAnalisador() == null || exameMarcacao.getToAnalisador().getNome() == null )? " " : exameMarcacao.getToAnalisador().getNome() );
Prestadores prestador = exameMarcacao.getToPrestadores();
List<Prestadores> allPrestadores = Prestadores.getAllPrestadores();
if( prestador == null )
{
prestador = Prestadores.prestadorNulo;
}
inputExameMarcacaoPrestador.setEditable( true );
inputExameMarcacaoPrestador.setObject( new OrderedMap<Prestadores>( allPrestadores ), prestador );
boolean editable = Prestadores.prestadorNulo.equals( prestador );
inputExameMarcacaoAnalisador.setCollapseOptions( false );
List<TrabalhadoresEcd> allECDS = exameMarcacao.getTrabalhadoresEcdArray();
OrderedMap<PrtGruposProtocolo> analisadoresForGrupos = new OrderedMap<PrtGruposProtocolo>();
if( allECDS != null )
{
for( TrabalhadoresEcd current : allECDS )
{
Prestadores currentAnalisador = current.getToAnalisador();
if( !prestador.equals( Prestadores.prestadorNulo ) )
{
currentAnalisador = prestador;
}
else if( currentAnalisador == null )
{
currentAnalisador = Prestadores.prestadorNulo;
}
PrtGruposProtocolo grupo = current.getToPrtTiposElementosProtocolo().getToPrtGruposProtocolo();
if( !analisadoresForGrupos.containsKey( grupo ) )
{
analisadoresForGrupos.putLast( grupo, grupo.getDescricao() );
LeafInputField<OrderedMap<Prestadores>> leaf = new LeafInputField<OrderedMap<Prestadores>>();
leaf.setObject( new OrderedMap<Prestadores>( allPrestadores ), currentAnalisador );
leaf.setEditable( editable );
analisadoresForGrupos.putLast( grupo, leaf );
}
}
}
inputExameMarcacaoAnalisador.setObject( analisadoresForGrupos );
inputExameMarcacaoAnalisador.setEditable( Prestadores.prestadorNulo.equals( prestador ) );
cardLayout.show( this, PANEL_EXAME_MARCACAO_NAME );
}
else
@ -429,16 +485,15 @@ public class ProcessoDadosPanel extends JPanel
}
}
@LeafUIActionBinding(action = CREATE_CONSULTA)
public void setForNewConsulta( TrabalhadoresConsultas consulta )
{
}
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO)
public void setForNewConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
{
LeafCalendarDialog calendar = new LeafCalendarDialog( getParentFrame(), this, false, false );
LeafCalendarDialog calendar = new LeafCalendarDialog( getParentFrame(), this, false, true );
Date date = calendar.getDate();
if( date == null )
{
parentWindow.abortAction( true );
}
marcacao.setData( date );
}
@ -452,49 +507,48 @@ public class ProcessoDadosPanel extends JPanel
email.setBody( mailDialog.getMessage() );
} catch( Exception e )
{
e.printStackTrace(System.out);
e.printStackTrace( System.out );
}
}
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES)
public void setForNewConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes )
{
LeafTextDialog textDialog = new LeafTextDialog( getParentFrame(), this, "", true);
LeafTextDialog textDialog = new LeafTextDialog( getParentFrame(), this, "", true );
String text = textDialog.getText();
observacoes.setObservacao( text );
inputConsultaMarcacaoObsMensagem.setEditable( true );
}
@LeafUIActionBinding(action = CREATE_EXAME)
public void setForNewExame( TrabalhadoresEcds exame )
{
}
@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO)
public void setForNewExameMarcacao( TrabalhadoresEcdsDatas marcacao )
{
LeafCalendarDialog calendar = new LeafCalendarDialog( getParentFrame(), this, false, false );
LeafCalendarDialog calendar = new LeafCalendarDialog( getParentFrame(), this, false, true );
Date date = calendar.getDate();
if( date == null )
{
parentWindow.abortAction( true );
}
marcacao.setData( date );
OrderedMap<PrtGruposProtocolo> allGrupos = marcacao.getToTrabalhadoresEcds().getGruposExamesForPerfil();
OrderedMap<PrtGruposProtocolo> grupos = new OrderedMap<PrtGruposProtocolo>();
Map<PrtGruposProtocolo, Boolean> gruposSelected = new HashMap<PrtGruposProtocolo, Boolean>();
for(int row = 0; row < allGrupos.rows(); ++row)
for( int row = 0; row < allGrupos.rows(); ++row )
{
List<Object> grupo = allGrupos.getValuesAt( row );
if( grupo != null && grupo.size() > 1)
List<Object> grupo = allGrupos.getRow( row );
if( grupo != null && grupo.size() > 1 )
{
String estado = grupo.get( 1 ).toString();
if(MedicinaConstants.ESTADOS_EXAME_STR[MedicinaConstants.ESTADO_POR_MARCAR].equals( estado ))
if( MedicinaConstants.ESTADOS_EXAME_STR[MedicinaConstants.ESTADO_POR_MARCAR].equals( estado ) )
{
PrtGruposProtocolo key = allGrupos.getKeyForValue( grupo );
gruposSelected.put( key , true );
grupos.addRow( key, grupo);
gruposSelected.put( key, true );
grupos.addRow( key, grupo );
}
}
}
LeafOptionDialog<PrtGruposProtocolo> gruposChosen = new LeafOptionDialog<PrtGruposProtocolo>( grupos, gruposSelected, null, "Escolha os ECDs para esta marca" +ccedil + atilde + "o" , "Marcar >>" );
LeafOptionDialog<PrtGruposProtocolo> gruposChosen = new LeafOptionDialog<PrtGruposProtocolo>( grupos, gruposSelected, null, "Escolha os ECDs para esta marca" + ccedil + atilde + "o", "Marcar >>" );
for( PrtGruposProtocolo grupo : gruposChosen.getSelected() )
{
marcacao.marcarGrupoExames( grupo );
@ -524,19 +578,11 @@ public class ProcessoDadosPanel extends JPanel
inputExameMarcacaoObsMensagem.setEditable( true );
}
@LeafUIActionBinding(action = SAVE_CONSULTA)
public void updateToSaveConsulta( TrabalhadoresConsultas consulta )
{
}
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO)
public void updateToSaveConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
{
}
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_EMAIL)
public void updateToSaveConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
{
Prestadores prestador = (Prestadores) inputConsultaMarcacaoPrestador.getSelectedObject();
marcacao.setToPrestadores( prestador );
}
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
@ -545,19 +591,28 @@ public class ProcessoDadosPanel extends JPanel
observacoes.setObservacao( inputConsultaMarcacaoObsMensagem.getObject() );
}
@LeafUIActionBinding(action = SAVE_EXAME)
public void updateToSaveExame( TrabalhadoresEcds exame )
{
}
@LeafUIActionBinding(action = SAVE_EXAME_MARCACAO)
public void updateToSaveExameMarcacao( TrabalhadoresEcdsDatas marcacao )
{
}
Prestadores prestador = (Prestadores) inputExameMarcacaoPrestador.getSelectedObject();
marcacao.setToPrestadores( prestador );
@LeafUIActionBinding(action = SAVE_EXAME_MARCACAO_EMAIL)
public void updateToSaveExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails email )
{
List<TrabalhadoresEcd> allEcd = marcacao.getTrabalhadoresEcdArray();
if( allEcd != null )
{
OrderedMap<PrtGruposProtocolo> map = inputExameMarcacaoAnalisador.getObject();
for( TrabalhadoresEcd ecd : allEcd )
{
PrtGruposProtocolo grupo = ecd.getToPrtTiposElementosProtocolo().getToPrtGruposProtocolo();
Object value = map.getValue( grupo, 1 );
if( value != null )
{
LeafInputField<OrderedMap<Prestadores>> leaf = (LeafInputField<OrderedMap<Prestadores>>) value;
Prestadores ecdAnalisador = Prestadores.prestadorNulo.equals( (Prestadores) leaf.getSelectedObject() ) ? null : ((Prestadores) leaf.getSelectedObject());
ecd.setToAnalisador( ecdAnalisador );
}
}
}
}
@LeafUIActionBinding(action = SAVE_EXAME_MARCACAO_OBSERVACOES)

@ -243,9 +243,10 @@ public class ProcessoTreePanel extends JPanel
public void refresh()
{
DefaultMutableTreeNode selected = getSelectedNode();
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
if( selected != null )
{
// ((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
mainTree.setSelectionPath( new TreePath( rootNode.getPath() ) );
mainTree.setSelectionPath( new TreePath( selected.getPath() ) );
}
revalidate();

@ -1,27 +1,27 @@
package siprp.medicina.processo.ui;
import static leaf.LeafLogic.ACTION_STARTUP;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
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.LOAD_TRABALHADOR;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Vector;
import java.util.Collection;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import leaf.LeafTableModel;
import leaf.LeafWindow;
import leaf.LeafLogic.LeafUIActionBinding;
import leaf.LeafWindow.ActionActivation;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import com.evolute.utils.tables.BaseTable;
import com.evolute.utils.tables.ColumnizedMappable;
import com.evolute.utils.tables.VectorTableModel;
public class TrabalhadoresChooserPanel extends JPanel
{
@ -31,15 +31,15 @@ public class TrabalhadoresChooserPanel extends JPanel
@ActionActivation(onSelect = SELECT_EMPRESA, onChange = "")
public BaseTable empresasTable;
public VectorTableModel empresasModel;
public LeafTableModel empresasModel;
@ActionActivation(onSelect = SELECT_ESTABELECIMENTO, onChange = "")
public BaseTable estabelecimentosTable;
public VectorTableModel estabelecimentosModel;
public LeafTableModel estabelecimentosModel;
@ActionActivation(onSelect = LOAD_TRABALHADOR, onChange = "")
public BaseTable trabalhadoresTable;
public VectorTableModel trabalhadoresModel;
public LeafTableModel trabalhadoresModel;
public TrabalhadoresChooserPanel(LeafWindow parentWindow)
{
@ -51,22 +51,22 @@ public class TrabalhadoresChooserPanel extends JPanel
private void setupComponents()
{
empresasModel = new VectorTableModel( new String[] {
"empresas"
empresasModel = new LeafTableModel( new String[] {
"Empresas"
} );
empresasTable = new BaseTable( empresasModel );
empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
empresasTable.setNonResizableNorReordable();
JScrollPane empresasScroll = new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
estabelecimentosModel = new VectorTableModel( new String[] {
"estabelecimentos"
estabelecimentosModel = new LeafTableModel( new String[] {
"Estabelecimentos"
} );
estabelecimentosTable = new BaseTable( estabelecimentosModel );
estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
estabelecimentosTable.setNonResizableNorReordable();
JScrollPane estabelecimentosScroll = new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
trabalhadoresModel = new VectorTableModel( new String[] {
"trabalhadores"
trabalhadoresModel = new LeafTableModel( new String[] {
"Trabalhadores"
} );
trabalhadoresTable = new BaseTable( trabalhadoresModel );
trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
@ -98,7 +98,7 @@ public class TrabalhadoresChooserPanel extends JPanel
}
@LeafUIActionBinding(action= ACTION_STARTUP)
public void fillEmpresas( Vector<ColumnizedMappable> allEmpresas )
public void fillEmpresas( Collection<Empresas> allEmpresas )
{
empresasTable.clearSelection();
empresasModel.clearAll();
@ -109,24 +109,24 @@ public class TrabalhadoresChooserPanel extends JPanel
}
@LeafUIActionBinding(action = SELECT_EMPRESA)
public void fillEstablecimentos( Vector<ColumnizedMappable> allEstabelecimentos )
public void fillEstablecimentos( Empresas empresa )
{
estabelecimentosTable.clearSelection();
estabelecimentosModel.clearAll();
if( allEstabelecimentos != null )
if( empresa != null )
{
estabelecimentosModel.setValues( allEstabelecimentos );
estabelecimentosModel.setValues( empresa.getEstabelecimentosArray() );
}
}
@LeafUIActionBinding(action = SELECT_ESTABELECIMENTO)
public void fillTrabalhadores( Vector<ColumnizedMappable> allTrabalhadores )
public void fillTrabalhadores(Estabelecimentos estabelecimento)
{
trabalhadoresTable.clearSelection();
trabalhadoresModel.clearAll();
if( allTrabalhadores != null )
if( estabelecimento != null )
{
trabalhadoresModel.setValues( allTrabalhadores );
trabalhadoresModel.setValues( estabelecimento.getTrabalhadoresArray() );
}
}

@ -29,7 +29,7 @@ public class UpdateList
new siprp.update.updates.V7_5_To_V7_6(), new siprp.update.updates.V7_6_To_V7_7(),
new siprp.update.updates.V7_7_To_V7_8(), new siprp.update.updates.V7_8_To_V7_9(),
new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1(),
new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3() };
new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3(), new siprp.update.updates.V8_3_To_V8_4() };
protected static Executer EXECUTER;
protected static double version = -1;

@ -0,0 +1,58 @@
/*
* V8_12_To_V8_3.java
*
* Created on December 19, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Field;
/**
*
* @author tsimao
*
*/
public class V8_3_To_V8_4 implements siprp.update.Update
{
public V8_3_To_V8_4()
{
}
public String[] listChanges()
{
return new String[] {
"Adicionado analisador [prestador] por TrabalhadorEcd"
};
}
public double getStartVersion()
{
return 8.3;
}
public double getEndVersion()
{
return 8.4;
}
public void doUpdate() throws Exception
{
DBManager dbm = (DBManager) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
Executer executer = dbm.getSharedExecuter();
com.evolute.utils.sql.Update update = new com.evolute.utils.sql.Update( "ALTER TABLE trabalhadores_ecd ADD COLUMN analisador_id int4;" + "ALTER TABLE trabalhadores_ecd ADD CONSTRAINT analisador_id_fkey FOREIGN KEY(analisador_id) REFERENCES prestadores(id);" );
executer.executeQuery( update );
}
public String toString()
{
return "v" + getStartVersion() + " para v" + getEndVersion();
}
}
Loading…
Cancel
Save