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

lxbfYeaa
Tiago Simão 17 years ago
parent b5c7fdabcc
commit 4d946887cc

@ -26,6 +26,7 @@ import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsEquipamentoMedico; import siprp.database.cayenne.objects.HsEquipamentoMedico;
import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico; import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico;
import siprp.logic.node.EquipamentoNode;
public class AdicionarEquipamentosPanel extends JPanel public class AdicionarEquipamentosPanel extends JPanel
{ {
@ -133,7 +134,7 @@ public class AdicionarEquipamentosPanel extends JPanel
{ {
if( relatorio != null ) if( relatorio != null )
{ {
String equipamentoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo equipamento m" + eacute + "dico", JOptionPane.QUESTION_MESSAGE ); String equipamentoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo equipamento de medi" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE );
if( equipamentoString != null ) if( equipamentoString != null )
{ {
HsEquipamentoMedico equipamento = new HsEquipamentoMedico(); HsEquipamentoMedico equipamento = new HsEquipamentoMedico();
@ -147,23 +148,7 @@ public class AdicionarEquipamentosPanel extends JPanel
} }
} }
} }
// private void save( DefaultMutableTreeNode toadd )
// {
// Object obj = toadd.getUserObject();
// if( obj instanceof HsPosto )
// {
// rel.save();
// }
// else
// {
// for( int i = 0; i < toadd.getChildCount(); ++i )
// {
// save( (DefaultMutableTreeNode) toadd.getChildAt( i ) );
// }
// }
// }
private void rem() private void rem()
{ {
TreePath path = tree.getSelectionPath(); TreePath path = tree.getSelectionPath();

@ -148,7 +148,7 @@ public class GerirMedidaPanel extends JPanel
private void placeComponents() private void placeComponents()
{ {
add( new JLabel("Requesitos legais"), new TableLayoutConstraints(0,0) ); add( new JLabel("Requisitos legais"), new TableLayoutConstraints(0,0) );
add( buttonSaveRequesito, new TableLayoutConstraints(1,0) ); add( buttonSaveRequesito, new TableLayoutConstraints(1,0) );
add( buttonRevertRequesito, new TableLayoutConstraints(2,0) ); add( buttonRevertRequesito, new TableLayoutConstraints(2,0) );
add( scrollRequesitos, new TableLayoutConstraints(0,1,2,1) ); add( scrollRequesitos, new TableLayoutConstraints(0,1,2,1) );

@ -237,8 +237,8 @@ public class GerirRiscosPanel extends JPanel
if( risco != null ) if( risco != null )
{ {
HsMedida medida = new HsMedida(); HsMedida medida = new HsMedida();
medida.setDescription( "(medida)" ); medida.setDescription( "" );
medida.setRequesitosLegais( "(requesitos legais)" ); medida.setRequesitosLegais( "" );
medida.save(); medida.save();
HsRiscoMedida rel = new HsRiscoMedida(); HsRiscoMedida rel = new HsRiscoMedida();
rel.setToHsRisco( risco ); rel.setToHsRisco( risco );

@ -1,148 +0,0 @@
package siprp.higiene.relatorio;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
public class AdicionarRiscosRelatorioPanel extends JPanel
{
private static final long serialVersionUID = 1L;
public static final String SELECTION_CHANGED = "RISCOS_SELECTION_CHANGED";
private final LeafButton buttonAdicionar = new LeafButton("Adicionar");
private final LeafButton buttonRemover = new LeafButton("Remover");
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
private final DefaultTreeModel model = new DefaultTreeModel( root );
public final JTree tree = new JTree( model );
private final JScrollPane scroll = new JScrollPane( tree );
private HsRelatorioPosto posto = null;
public AdicionarRiscosRelatorioPanel()
{
startupComponents();
setupLayout();
placeComponents();
startupListeners();
}
private void startupComponents()
{
buttonAdicionar.setEnabled( false );
buttonRemover.setEnabled( false );
tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
}
private void setupLayout()
{
TableLayout layout = new TableLayout(
new double[]{ TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
);
layout.setHGap( 5 );
layout.setVGap( 5 );
setLayout( layout );
}
private void placeComponents()
{
JPanel panel = new JPanel();
TableLayout layout = new TableLayout(
new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM },
new double[]{ TableLayout.MINIMUM }
);
layout.setHGap( 5 );
layout.setVGap( 5 );
panel.setLayout( layout );
panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) );
panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) );
add( panel, new TableLayoutConstraints( 0, 0 ) );
add( scroll, new TableLayoutConstraints( 0, 1 ) );
}
private void startupListeners()
{
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){
@Override
public void valueChanged( TreeSelectionEvent e )
{
setEnabled();
Object object = null;
TreePath path = tree.getSelectionPath();
if( path != null )
{
Object selection = path.getLastPathComponent();
if( selection instanceof RiscoRelatorioNode )
{
object = selection == null ? null : ((RiscoRelatorioNode)selection).getUserObject();
}
else if( selection instanceof MedidaRelatorioNode )
{
object = selection == null ? null : ((MedidaRelatorioNode)selection).getUserObject();
}
}
firePropertyChange( SELECTION_CHANGED, null, object );
}
} );
}
private void setEnabled()
{
}
public void refresh()
{
root.removeAllChildren();
if( posto != null )
{
for( HsRelatorioPostoRisco rel : posto.getHsRelatorioPostoRiscoArray() )
{
RiscoRelatorioNode node = new RiscoRelatorioNode( rel );
if( rel.getToHsRelatorioRisco() != null )
{
for( HsRelatorioPostoMedida medida : posto.getHsRelatorioPostoMedidaArray() )
{
if( rel.getToHsRelatorioPosto().equals( medida.getToHsRelatorioPosto() ) )
{
node.add( new MedidaRelatorioNode(medida) );
}
}
}
root.add( node );
}
}
setEnabled();
TreeTools.refreshTree( tree, root );
}
public void setPosto( HsRelatorioPosto posto )
{
this.posto = posto;
refresh();
}
}

@ -1,17 +0,0 @@
package siprp.higiene.relatorio;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioArea;
public class AreaRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public AreaRelatorioNode( HsRelatorioArea risco )
{
super( risco );
}
}

@ -171,7 +171,7 @@ public class GerirMedidaRelatorioPanel extends JPanel
panel.setLayout( layout ); panel.setLayout( layout );
panel.add( checkPlanoActuacao, new TableLayoutConstraints(0,0) ); panel.add( checkPlanoActuacao, new TableLayoutConstraints(0,0) );
add( panel, new TableLayoutConstraints(0,0,2,0) ); add( panel, new TableLayoutConstraints(0,0,2,0) );
add( new JLabel("Requesitos legais"), new TableLayoutConstraints(0,1) ); add( new JLabel("Requisitos legais"), new TableLayoutConstraints(0,1) );
add( buttonSaveRequesito, new TableLayoutConstraints(1,1) ); add( buttonSaveRequesito, new TableLayoutConstraints(1,1) );
add( buttonRevertRequesito, new TableLayoutConstraints(2,1) ); add( buttonRevertRequesito, new TableLayoutConstraints(2,1) );
add( scrollRequesitos, new TableLayoutConstraints(0,2,2,2) ); add( scrollRequesitos, new TableLayoutConstraints(0,2,2,2) );
@ -189,6 +189,7 @@ public class GerirMedidaRelatorioPanel extends JPanel
boolean requesitoChanged = false; boolean requesitoChanged = false;
if( relacao != null ) if( relacao != null )
{ {
checkPlanoActuacao.setEnabled( true );
medidaChanged = !fieldTextMedida.getText().equals( relacao.getToHsRelatorioMedida().getDescription() ); medidaChanged = !fieldTextMedida.getText().equals( relacao.getToHsRelatorioMedida().getDescription() );
requesitoChanged = !fieldTextRequisitosLegais.getText().equals( relacao.getToHsRelatorioMedida().getRequesitosLegais() ); requesitoChanged = !fieldTextRequisitosLegais.getText().equals( relacao.getToHsRelatorioMedida().getRequesitosLegais() );
} }
@ -207,6 +208,7 @@ public class GerirMedidaRelatorioPanel extends JPanel
buttonRevertRequesito.setEnabled( false ); buttonRevertRequesito.setEnabled( false );
fieldTextRequisitosLegais.setEnabled( false ); fieldTextRequisitosLegais.setEnabled( false );
fieldTextMedida.setEnabled( false ); fieldTextMedida.setEnabled( false );
checkPlanoActuacao.setEnabled( false );
} }
} }

@ -0,0 +1,287 @@
package siprp.higiene.relatorio;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsRelatorioMedida;
import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.logic.HigieneSegurancaLogic;
import siprp.logic.node.MedidaRelatorioNode;
import siprp.logic.node.RiscoRelatorioNode;
public class GerirMedidasRelatorioPanel extends JPanel
{
private static final long serialVersionUID = 1L;
public static final String SELECTION_CHANGED = "RISCOS_SELECTION_CHANGED";
private final LeafButton buttonAdicionar = new LeafButton("Adicionar");
private final LeafButton buttonRemover = new LeafButton("Remover");
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
private final DefaultTreeModel model = new DefaultTreeModel( root );
public final JTree tree = new JTree( model );
private final JScrollPane scroll = new JScrollPane( tree );
private HsRelatorioPosto posto = null;
public GerirMedidasRelatorioPanel()
{
startupComponents();
setupLayout();
placeComponents();
startupListeners();
}
private void startupComponents()
{
buttonAdicionar.setEnabled( false );
buttonRemover.setEnabled( false );
tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
tree.setCellRenderer(new DefaultTreeCellRenderer()
{
private static final long serialVersionUID = 1L;
public Component getTreeCellRendererComponent(JTree pTree, Object pValue, boolean pIsSelected, boolean pIsExpanded, boolean pIsLeaf, int pRow, boolean pHasFocus)
{
super.getTreeCellRendererComponent(pTree, pValue, pIsSelected, pIsExpanded, pIsLeaf, pRow, pHasFocus);
boolean highlight= false;
if( pValue instanceof RiscoRelatorioNode )
{
Object userObject = ((RiscoRelatorioNode)pValue).getUserObject();
if( userObject instanceof HsRelatorioPostoRisco )
{
highlight = HigieneSegurancaLogic.isRelatorioRiscoPreenchido( (HsRelatorioPostoRisco) userObject );
}
}
if( highlight )
{
setOpaque( true );
setBackground( pIsSelected ? RelatorioHigieneSegurancaWindow.COLOR_OK_SEL : RelatorioHigieneSegurancaWindow.COLOR_OK );
}
else
{
setOpaque( false );
}
return(this);
}
});
}
private void setupLayout()
{
TableLayout layout = new TableLayout(
new double[]{ TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
);
layout.setHGap( 5 );
layout.setVGap( 5 );
setLayout( layout );
}
private void placeComponents()
{
JPanel panel = new JPanel();
TableLayout layout = new TableLayout(
new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM },
new double[]{ TableLayout.MINIMUM }
);
layout.setHGap( 5 );
layout.setVGap( 5 );
panel.setLayout( layout );
panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) );
panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) );
add( panel, new TableLayoutConstraints( 0, 0 ) );
add( scroll, new TableLayoutConstraints( 0, 1 ) );
}
private void startupListeners()
{
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){
@Override
public void valueChanged( TreeSelectionEvent e )
{
Object object = null;
TreePath path = tree.getSelectionPath();
if( path != null )
{
Object selection = path.getLastPathComponent();
if( selection instanceof RiscoRelatorioNode )
{
object = selection == null ? null : ((RiscoRelatorioNode)selection).getUserObject();
}
else if( selection instanceof MedidaRelatorioNode )
{
object = selection == null ? null : ((MedidaRelatorioNode)selection).getUserObject();
}
}
setEnabled();
firePropertyChange( SELECTION_CHANGED, null, object );
}
} );
buttonAdicionar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
add();
}
} );
buttonRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
rem();
}
} );
}
private HsRelatorioPostoRisco getSelectedRisco()
{
HsRelatorioPostoRisco result = null;
TreePath path = tree.getSelectionPath();
if( path != null )
{
Object selection = path.getLastPathComponent();
if( selection instanceof RiscoRelatorioNode )
{
result = selection == null ? null : (HsRelatorioPostoRisco) ((RiscoRelatorioNode)selection).getUserObject();
}
}
return result;
}
private HsRelatorioPostoMedida getSelectedMedida()
{
HsRelatorioPostoMedida result = null;
TreePath path = tree.getSelectionPath();
if( path != null )
{
Object selection = path.getLastPathComponent();
if( selection instanceof MedidaRelatorioNode )
{
result = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode)selection).getUserObject();
}
}
return result;
}
private void add()
{
HsRelatorioPostoRisco postoRisco = getSelectedRisco();
if( posto != null )
{
HsRelatorioMedida medida = new HsRelatorioMedida();
medida.setDescription( "" );
medida.setRequesitosLegais( "" );
medida.setToHsRelatorioRisco( postoRisco.getToHsRelatorioRisco() );
HsRelatorioPostoMedida rel = new HsRelatorioPostoMedida();
rel.setToHsRelatorioMedida( medida );
rel.setToHsRelatorioPosto( posto );
rel.save();
}
refresh();
setEnabled();
}
private void rem()
{
TreePath path = tree.getSelectionPath();
if( path != null )
{
Object selection = path.getLastPathComponent();
if( selection instanceof MedidaRelatorioNode )
{
HsRelatorioPostoMedida rel = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode)selection).getUserObject();
rel.getToHsRelatorioMedida().delete();
rel.delete();
}
}
refresh();
setEnabled();
}
private void setEnabled()
{
boolean add = false;
boolean rem = false;
if( posto!= null )
{
if( posto.getToHsRelatorioArea() != null && posto.getToHsRelatorioArea().getToHsRelatorio() != null && posto.getToHsRelatorioArea().getToHsRelatorio().getIsSubmetido() == null )
{
add = true;
rem = true;
}
}
buttonAdicionar.setEnabled( add && getSelectedRisco() != null );
buttonRemover.setEnabled( rem && getSelectedMedida() != null );
}
public void refresh()
{
root.removeAllChildren();
if( posto != null )
{
for( HsRelatorioPostoRisco rel : posto.getHsRelatorioPostoRiscoArray() )
{
RiscoRelatorioNode node = new RiscoRelatorioNode( rel );
if( rel.getToHsRelatorioRisco() != null )
{
for( HsRelatorioPostoMedida medida : posto.getHsRelatorioPostoMedidaArray() )
{
if( rel.getToHsRelatorioPosto().equals( medida.getToHsRelatorioPosto() ) )
{
node.add( new MedidaRelatorioNode(medida) );
}
}
}
root.add( node );
}
}
setEnabled();
TreeTools.refreshTree( tree, root );
}
public void setPosto( HsRelatorioPosto posto )
{
this.posto = posto;
refresh();
setEnabled();
}
}

@ -7,18 +7,15 @@ import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JComponent; import javax.swing.JFormattedTextField;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.event.CaretEvent; import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener; import javax.swing.event.CaretListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import leaf.ui.LeafButton; import leaf.ui.LeafButton;
import leaf.ui.LeafIconButton; import leaf.ui.LeafIconButton;
@ -26,31 +23,35 @@ import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo; import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo;
import siprp.logic.HigieneSegurancaLogic; import siprp.logic.HigieneSegurancaLogic;
import static com.evolute.utils.strings.UnicodeLatin1Map.*;
public class GerirValoresRiscoPanel extends JPanel implements ActionListener, CaretListener public class GerirValoresRiscoPanel extends JPanel implements ActionListener, CaretListener
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png"; private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png";
private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png"; private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png";
public static final String VALUE_CHANGED = "VALUE_CHANGED";
private final JRadioButton radioValorQuantitativo = new JRadioButton(); private final JRadioButton radioValorQuantitativo = new JRadioButton();
private final JRadioButton radioValorQualitativo = new JRadioButton(); private final JRadioButton radioValorQualitativo = new JRadioButton();
private final JTextField textSeveridade = new JTextField(); private final JFormattedTextField textSeveridade = new JFormattedTextField();
private final JTextField textProbabilidade = new JTextField(); private final JFormattedTextField textProbabilidade = new JFormattedTextField();
private final JComboBox comboValorQualitativo = new JComboBox(); private final JComboBox comboValorQualitativo = new JComboBox();
private final LeafButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE ); private final LeafButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE );
private final LeafButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT); private final LeafButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
private final ButtonGroup bg = new ButtonGroup(); private final ButtonGroup bg = new ButtonGroup();
private HsRelatorioPostoRisco valoresRisco = null; private HsRelatorioPostoRisco valoresRisco = null;
public GerirValoresRiscoPanel() public GerirValoresRiscoPanel()
@ -61,7 +62,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
placeComponents(); placeComponents();
loadValoresQualitativos(); loadValoresQualitativos();
} }
private void startupListeners() private void startupListeners()
{ {
radioValorQualitativo.addActionListener( this ); radioValorQualitativo.addActionListener( this );
@ -85,8 +86,9 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
refresh(); refresh();
} }
} ); } );
} }
private void startupComponents() private void startupComponents()
{ {
textSeveridade.setPreferredSize( new Dimension( 30, 0 ) ); textSeveridade.setPreferredSize( new Dimension( 30, 0 ) );
@ -96,41 +98,43 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
bg.add( radioValorQualitativo ); bg.add( radioValorQualitativo );
bg.add( radioValorQuantitativo ); bg.add( radioValorQuantitativo );
} }
private void startupLayout() private void startupLayout()
{ {
TableLayout layout = new TableLayout( TableLayout layout = new TableLayout( new double[] {
new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL }, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL
new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM } }, new double[] {
); TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM
} );
layout.setVGap( 5 ); layout.setVGap( 5 );
layout.setHGap( 5 ); layout.setHGap( 5 );
setLayout( layout ); setLayout( layout );
} }
private void placeComponents() private void placeComponents()
{ {
TableLayout layout = new TableLayout( TableLayout layout = new TableLayout( new double[] {
new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM }, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM
new double[]{ TableLayout.MINIMUM } }, new double[] {
); TableLayout.MINIMUM
} );
layout.setVGap( 5 ); layout.setVGap( 5 );
layout.setHGap( 5 ); layout.setHGap( 5 );
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout( layout ); panel.setLayout( layout );
panel.add( buttonSave, new TableLayoutConstraints( 1, 0 ) ); panel.add( buttonSave, new TableLayoutConstraints( 1, 0 ) );
panel.add( buttonRevert, new TableLayoutConstraints( 2, 0 ) ); panel.add( buttonRevert, new TableLayoutConstraints( 2, 0 ) );
add( panel, new TableLayoutConstraints(1,0,6,0) ); add( panel, new TableLayoutConstraints( 1, 0, 6, 0 ) );
add( radioValorQuantitativo, new TableLayoutConstraints( 0, 1 ) ); add( radioValorQuantitativo, new TableLayoutConstraints( 0, 1 ) );
add( new JLabel("Severidade"), new TableLayoutConstraints( 1, 1 ) ); add( new JLabel( "Severidade" ), new TableLayoutConstraints( 1, 1 ) );
add( textSeveridade, new TableLayoutConstraints( 2, 1 ) ); add( textSeveridade, new TableLayoutConstraints( 2, 1 ) );
add( new JLabel("Probabilidade"), new TableLayoutConstraints( 4, 1 ) ); add( new JLabel( "Probabilidade" ), new TableLayoutConstraints( 4, 1 ) );
add( textProbabilidade, new TableLayoutConstraints( 5, 1 ) ); add( textProbabilidade, new TableLayoutConstraints( 5, 1 ) );
add( radioValorQualitativo, new TableLayoutConstraints( 0, 2 ) ); add( radioValorQualitativo, new TableLayoutConstraints( 0, 2 ) );
add( comboValorQualitativo, new TableLayoutConstraints( 1, 2, 5, 2 ) ); add( comboValorQualitativo, new TableLayoutConstraints( 1, 2, 5, 2 ) );
} }
private void loadValoresQualitativos() private void loadValoresQualitativos()
{ {
comboValorQualitativo.removeAllItems(); comboValorQualitativo.removeAllItems();
@ -140,7 +144,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
} }
} }
private void refresh() void refresh()
{ {
if( valoresRisco != null ) if( valoresRisco != null )
{ {
@ -149,7 +153,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
radioValorQualitativo.setSelected( qualitativo ); radioValorQualitativo.setSelected( qualitativo );
String severidade = (valoresRisco.getSeveridade() == null ? null : valoresRisco.getSeveridade() + ""); String severidade = (valoresRisco.getSeveridade() == null ? null : valoresRisco.getSeveridade() + "");
String probabilidade = (valoresRisco.getProbabilidade() == null ? null : valoresRisco.getProbabilidade() + ""); String probabilidade = (valoresRisco.getProbabilidade() == null ? null : valoresRisco.getProbabilidade() + "");
textSeveridade.setText( severidade ); textSeveridade.setText( severidade );
textProbabilidade.setText( probabilidade ); textProbabilidade.setText( probabilidade );
if( valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null ) if( valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null )
{ {
@ -163,7 +167,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
textProbabilidade.setText( null ); textProbabilidade.setText( null );
} }
} }
private void setEnabled() private void setEnabled()
{ {
if( isEnabled() ) if( isEnabled() )
@ -178,11 +182,11 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
boolean changes = false; boolean changes = false;
boolean wasQual = valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null; boolean wasQual = valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null;
boolean isQual = radioValorQualitativo.isSelected(); boolean isQual = radioValorQualitativo.isSelected();
if(!isQual) if( !isQual )
{ {
changes = wasQual; changes = wasQual;
if(!changes) if( !changes )
{ {
boolean probChanged = false; boolean probChanged = false;
boolean sevChanged = false; boolean sevChanged = false;
String prob = textProbabilidade.getText(); String prob = textProbabilidade.getText();
@ -193,7 +197,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
} }
else else
{ {
probChanged = !prob.equals(valoresRisco.getProbabilidade() == null ? "" : valoresRisco.getProbabilidade() + ""); probChanged = !prob.equals( valoresRisco.getProbabilidade() == null ? "" : valoresRisco.getProbabilidade() + "" );
} }
if( sev == null ) if( sev == null )
{ {
@ -201,7 +205,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
} }
else else
{ {
sevChanged = !sev.equals(valoresRisco.getSeveridade() == null ? "" : valoresRisco.getSeveridade() + "" ); sevChanged = !sev.equals( valoresRisco.getSeveridade() == null ? "" : valoresRisco.getSeveridade() + "" );
} }
changes = probChanged || sevChanged; changes = probChanged || sevChanged;
} }
@ -209,8 +213,8 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
else else
{ {
changes = !wasQual; changes = !wasQual;
if(!changes) if( !changes )
{ {
changes = !comboValorQualitativo.getSelectedItem().equals( valoresRisco.getToHsRelatorioRiscoValorQualitativo() ); changes = !comboValorQualitativo.getSelectedItem().equals( valoresRisco.getToHsRelatorioRiscoValorQualitativo() );
} }
} }
@ -229,14 +233,19 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
textSeveridade.setEnabled( false ); textSeveridade.setEnabled( false );
} }
} }
public void setRelatorioPostoRisco( HsRelatorioPostoRisco rel ) public void setRelatorioPostoRisco( HsRelatorioPostoRisco rel )
{ {
this.valoresRisco = rel; this.valoresRisco = rel;
refresh(); refresh();
setEnabled(); setEnabled();
} }
private void error( boolean probabilidade )
{
JOptionPane.showMessageDialog( this, "Valor inv" + aacute + "lido para " + (probabilidade ? "'Probabilidade'" : "'Severidade'") + ".", "Erro", JOptionPane.ERROR_MESSAGE, null );
}
private void save() private void save()
{ {
if( valoresRisco != null ) if( valoresRisco != null )
@ -248,26 +257,48 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
else else
{ {
valoresRisco.setToHsRelatorioRiscoValorQualitativo( null ); valoresRisco.setToHsRelatorioRiscoValorQualitativo( null );
Integer probabilidade = 0; Integer probabilidade = null;
Integer severidade = 0; Integer severidade = null;
try{ boolean ok = true;
probabilidade = new Integer(textProbabilidade.getText() != null ? textProbabilidade.getText() : "0" ); if( textProbabilidade.getText() != null && !textProbabilidade.getText().trim().equals( "" ) )
}
catch (NumberFormatException e1)
{ {
e1.printStackTrace(); try
} {
try{ probabilidade = new Integer( textProbabilidade.getText() );
severidade = new Integer(textSeveridade.getText() != null ? textSeveridade.getText() : "0" ); } catch( NumberFormatException e1 )
{
ok = false;
}
if(!ok || !HigieneSegurancaLogic.isProbabilidadeValida( probabilidade ) )
{
error(true);
}
} }
catch (NumberFormatException e2) if( textSeveridade.getText() != null && !textSeveridade.getText().trim().equals( "" ) )
{ {
e2.printStackTrace(); if( ok )
{
try
{
severidade = new Integer( textSeveridade.getText() );
} catch( NumberFormatException e2 )
{
ok = false;
}
if(!ok || !HigieneSegurancaLogic.isSeveridadeValida( severidade ) )
{
error(false);
}
}
} }
valoresRisco.setProbabilidade( probabilidade ); boolean pvalid = HigieneSegurancaLogic.isProbabilidadeValida( probabilidade );
valoresRisco.setSeveridade( severidade ); boolean svalid = HigieneSegurancaLogic.isSeveridadeValida( severidade );
valoresRisco.setProbabilidade( pvalid && svalid ? probabilidade : null );
valoresRisco.setSeveridade( pvalid && svalid ? severidade : null );
} }
valoresRisco.save(); valoresRisco.save();
firePropertyChange( VALUE_CHANGED, null, valoresRisco );
refresh(); refresh();
setEnabled(); setEnabled();
} }

@ -1,16 +0,0 @@
package siprp.higiene.relatorio;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
public class MedidaRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public MedidaRelatorioNode( HsRelatorioPostoMedida medida )
{
super( medida );
}
}

@ -93,7 +93,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
bg.add( radioInicial ); bg.add( radioInicial );
bg.add( radioPeriodica ); bg.add( radioPeriodica );
panelAcompanhantes.setBorder( BorderFactory.createTitledBorder( "Pessoas que acompanharam" ) ); panelAcompanhantes.setBorder( BorderFactory.createTitledBorder( "Pessoas que acompanharam" ) );
panelEquipamentos.setBorder( BorderFactory.createTitledBorder( "Equipamentos m"+eacute+"dicos" ) ); panelEquipamentos.setBorder( BorderFactory.createTitledBorder( "Equipamentos de medi"+ccedil+atilde+"o" ) );
tabs.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano ); tabs.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano );
tabs.addTab( "Legisla" + ccedil + otilde + "es", panelLegislacao ); tabs.addTab( "Legisla" + ccedil + otilde + "es", panelLegislacao );
} }
@ -294,13 +294,17 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
buttonSubmit.setEnabled( enabled ); buttonSubmit.setEnabled( enabled );
} }
public void setRelatorio( HsRelatorio relatorio ) public void setRelatorio( HsRelatorio relatorio,boolean create )
{ {
this.relatorio = relatorio; this.relatorio = relatorio;
buttonSave.setEnabled( false ); buttonSave.setEnabled( false );
buttonRevert.setEnabled( false ); buttonRevert.setEnabled( false );
panelEquipamentos.setRelatorio( relatorio ); panelEquipamentos.setRelatorio( relatorio );
panelPlano.setRelatorio( relatorio ); panelPlano.setRelatorio( relatorio );
if( create )
{
panelPlano.revert(false);
}
refresh(); refresh();
setEnabled(); setEnabled();
} }

@ -27,7 +27,7 @@ public class PlanoActuacaoPanel extends JPanel
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png"; private static final String ICON_NAME_REVERT = "siprp/higiene/relatorio/revert.png";
private static final String RISCO_PANEL = "RISCO_PANEL"; private static final String RISCO_PANEL = "RISCO_PANEL";
@ -35,9 +35,9 @@ public class PlanoActuacaoPanel extends JPanel
private static final String EMPTY_PANEL = "EMPTY_PANEL"; private static final String EMPTY_PANEL = "EMPTY_PANEL";
private final AdicionarAreasRelatorioPanel areas = new AdicionarAreasRelatorioPanel(); private final VerAreasRelatorioPanel areas = new VerAreasRelatorioPanel();
private final AdicionarRiscosRelatorioPanel riscos = new AdicionarRiscosRelatorioPanel(); private final GerirMedidasRelatorioPanel riscos = new GerirMedidasRelatorioPanel();
private final GerirValoresRiscoPanel valoresRisco = new GerirValoresRiscoPanel(); private final GerirValoresRiscoPanel valoresRisco = new GerirValoresRiscoPanel();
@ -64,7 +64,7 @@ public class PlanoActuacaoPanel extends JPanel
private void startupListeners() private void startupListeners()
{ {
areas.addPropertyChangeListener( AdicionarAreasRelatorioPanel.SELECTION_CHANGED, new PropertyChangeListener() areas.addPropertyChangeListener( VerAreasRelatorioPanel.SELECTION_CHANGED, new PropertyChangeListener()
{ {
@Override @Override
public void propertyChange( PropertyChangeEvent evt ) public void propertyChange( PropertyChangeEvent evt )
@ -79,7 +79,7 @@ public class PlanoActuacaoPanel extends JPanel
} }
} }
} ); } );
riscos.addPropertyChangeListener( AdicionarRiscosRelatorioPanel.SELECTION_CHANGED, new PropertyChangeListener() riscos.addPropertyChangeListener( GerirMedidasRelatorioPanel.SELECTION_CHANGED, new PropertyChangeListener()
{ {
@Override @Override
public void propertyChange( PropertyChangeEvent evt ) public void propertyChange( PropertyChangeEvent evt )
@ -107,16 +107,28 @@ public class PlanoActuacaoPanel extends JPanel
@Override @Override
public void actionPerformed( ActionEvent e ) public void actionPerformed( ActionEvent e )
{ {
revert(); revert(true);
}
} );
valoresRisco.addPropertyChangeListener( GerirValoresRiscoPanel.VALUE_CHANGED, new PropertyChangeListener()
{
@Override
public void propertyChange( PropertyChangeEvent evt )
{
if( evt.getNewValue() instanceof HsRelatorioPostoRisco )
{
riscos.repaint();
areas.repaint();
}
} }
} ); } );
} }
private void revert() protected void revert( boolean ask )
{ {
if( relatorio != null ) if( relatorio != null )
{ {
int ret = JOptionPane.showConfirmDialog( this, "Todas as altera" + ccedil + otilde + "es ao plano de actua" + ccedil + atilde + "o ser" + atilde + "o perdidas\nTem a certeza?","Carregar configura"+ccedil+atilde+"o actual ",JOptionPane.YES_NO_OPTION); int ret = ask == false ? JOptionPane.YES_OPTION : JOptionPane.showConfirmDialog( this, "Todas as altera" + ccedil + otilde + "es ao plano de actua" + ccedil + atilde + "o ser" + atilde + "o perdidas\nTem a certeza?","Carregar dados do estabelecimento",JOptionPane.YES_NO_OPTION);
if( JOptionPane.YES_OPTION == ret ) if( JOptionPane.YES_OPTION == ret )
{ {
HigieneSegurancaLogic.reverterRelatorio(relatorio); HigieneSegurancaLogic.reverterRelatorio(relatorio);
@ -127,8 +139,9 @@ public class PlanoActuacaoPanel extends JPanel
private void startupComponents() private void startupComponents()
{ {
riscos.setBorder( BorderFactory.createTitledBorder( "Riscos" ) ); riscos.setBorder( BorderFactory.createTitledBorder( "Medidas" ) );
areas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) ); areas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) );
buttonRevert.setToolTipText( "Carregar dados do estabelecimento" );
} }
private void startupLayout() private void startupLayout()

@ -1,17 +0,0 @@
package siprp.higiene.relatorio;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioPosto;
public class PostoRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public PostoRelatorioNode( HsRelatorioPosto risco )
{
super( risco );
}
}

@ -5,11 +5,11 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.oacute;
import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints; import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Color;
import java.awt.Container; import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.peer.PanelPeer;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -31,6 +31,10 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static final Color COLOR_OK = new Color(200,255,200);
public static final Color COLOR_OK_SEL = new Color(140,240,140);
public static final String TITLE = "Relat" + oacute + "rios de Higiene e Seguran" + ccedil + "a no Trabalho"; public static final String TITLE = "Relat" + oacute + "rios de Higiene e Seguran" + ccedil + "a no Trabalho";
public static final Dimension SIZE = new Dimension( 1024, 700 ); public static final Dimension SIZE = new Dimension( 1024, 700 );
@ -152,7 +156,8 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable
private void fillRelatorio( MarcacoesEstabelecimento visita ) private void fillRelatorio( MarcacoesEstabelecimento visita )
{ {
panelRelatorio.setRelatorio( null ); boolean carregarDadosEstabelecimento = false;
panelRelatorio.setRelatorio( null, carregarDadosEstabelecimento );
if( visita != null ) if( visita != null )
{ {
HsRelatorio relatorio = null; HsRelatorio relatorio = null;
@ -173,8 +178,9 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable
relatorio.setData( new Date() ); relatorio.setData( new Date() );
relatorio.setToHsMarcacoesEstabelecimento( visita ); relatorio.setToHsMarcacoesEstabelecimento( visita );
relatorio.save(); relatorio.save();
carregarDadosEstabelecimento = true;
} }
panelRelatorio.setRelatorio( relatorio ); panelRelatorio.setRelatorio( relatorio, carregarDadosEstabelecimento );;
} }
} }

@ -1,16 +0,0 @@
package siprp.higiene.relatorio;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
public class RiscoRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public RiscoRelatorioNode( HsRelatorioPostoRisco risco )
{
super( risco );
}
}

@ -3,33 +3,33 @@ package siprp.higiene.relatorio;
import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints; import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Component;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel; import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.TreeTools; import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioPosto; import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.logic.HigieneSegurancaLogic; import siprp.logic.HigieneSegurancaLogic;
import siprp.logic.node.PostoRelatorioNode;
public class AdicionarAreasRelatorioPanel extends JPanel public class VerAreasRelatorioPanel extends JPanel
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static final String SELECTION_CHANGED = "SELECTION_CHANGED"; public static final String SELECTION_CHANGED = "SELECTION_CHANGED";
private final LeafButton buttonAdicionar = new LeafButton("Adicionar");
private final LeafButton buttonRemover = new LeafButton("Remover");
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode(); private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
private final DefaultTreeModel model = new DefaultTreeModel( root ); private final DefaultTreeModel model = new DefaultTreeModel( root );
@ -40,7 +40,7 @@ public class AdicionarAreasRelatorioPanel extends JPanel
private HsRelatorio relatorio = null; private HsRelatorio relatorio = null;
public AdicionarAreasRelatorioPanel() public VerAreasRelatorioPanel()
{ {
startupComponents(); startupComponents();
setupLayout(); setupLayout();
@ -50,10 +50,44 @@ public class AdicionarAreasRelatorioPanel extends JPanel
private void startupComponents() private void startupComponents()
{ {
buttonAdicionar.setEnabled( false );
buttonRemover.setEnabled( false );
tree.setRootVisible( false ); tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
tree.setCellRenderer(new DefaultTreeCellRenderer()
{
private static final long serialVersionUID = 1L;
public Component getTreeCellRendererComponent(JTree pTree, Object pValue, boolean pIsSelected, boolean pIsExpanded, boolean pIsLeaf, int pRow, boolean pHasFocus)
{
super.getTreeCellRendererComponent(pTree, pValue, pIsSelected, pIsExpanded, pIsLeaf, pRow, pHasFocus);
boolean highlight= false;
if( pValue instanceof PostoRelatorioNode )
{
Object userObject = ((PostoRelatorioNode)pValue).getUserObject();
if( userObject instanceof HsRelatorioPosto )
{
HsRelatorioPosto posto = (HsRelatorioPosto) userObject;
boolean allOk = true;
for( HsRelatorioPostoRisco rel : posto.getHsRelatorioPostoRiscoArray() )
{
allOk &= HigieneSegurancaLogic.isRelatorioRiscoPreenchido( rel );
}
highlight = allOk;
}
}
if( highlight )
{
setOpaque( true );
setBackground( pIsSelected ? RelatorioHigieneSegurancaWindow.COLOR_OK_SEL : RelatorioHigieneSegurancaWindow.COLOR_OK );
}
else
{
setOpaque( false );
}
return(this);
}
});
} }
private void setupLayout() private void setupLayout()
@ -77,8 +111,8 @@ public class AdicionarAreasRelatorioPanel extends JPanel
layout.setHGap( 5 ); layout.setHGap( 5 );
layout.setVGap( 5 ); layout.setVGap( 5 );
panel.setLayout( layout ); panel.setLayout( layout );
panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); // panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) );
panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); // panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) );
add( panel, new TableLayoutConstraints( 0, 0 ) ); add( panel, new TableLayoutConstraints( 0, 0 ) );
add( scroll, new TableLayoutConstraints( 0, 1 ) ); add( scroll, new TableLayoutConstraints( 0, 1 ) );
@ -101,8 +135,8 @@ public class AdicionarAreasRelatorioPanel extends JPanel
private void setEnabled() private void setEnabled()
{ {
buttonAdicionar.setEnabled( false ); // buttonAdicionar.setEnabled( false );
buttonRemover.setEnabled( false ); // buttonRemover.setEnabled( false );
} }
public void refresh() public void refresh()

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

@ -1853,8 +1853,8 @@
<obj-relationship name="hsRelatorioPostoMedidaArray" source="HsRelatorioPosto" target="HsRelatorioPostoMedida" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoMedidaArray"/> <obj-relationship name="hsRelatorioPostoMedidaArray" source="HsRelatorioPosto" target="HsRelatorioPostoMedida" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoMedidaArray"/>
<obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioPosto" target="HsRelatorioPostoRisco" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoRiscoArray"/> <obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioPosto" target="HsRelatorioPostoRisco" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoRiscoArray"/>
<obj-relationship name="toHsRelatorioArea" source="HsRelatorioPosto" target="HsRelatorioArea" deleteRule="Nullify" db-relationship-path="toHsRelatorioArea"/> <obj-relationship name="toHsRelatorioArea" source="HsRelatorioPosto" target="HsRelatorioArea" deleteRule="Nullify" db-relationship-path="toHsRelatorioArea"/>
<obj-relationship name="toHsRelatorioMedida" source="HsRelatorioPostoMedida" target="HsRelatorioMedida" deleteRule="Cascade" db-relationship-path="toHsRelatorioMedida"/> <obj-relationship name="toHsRelatorioMedida" source="HsRelatorioPostoMedida" target="HsRelatorioMedida" deleteRule="Nullify" db-relationship-path="toHsRelatorioMedida"/>
<obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoMedida" target="HsRelatorioPosto" deleteRule="Cascade" db-relationship-path="toHsRelatorioPosto"/> <obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoMedida" target="HsRelatorioPosto" deleteRule="Nullify" db-relationship-path="toHsRelatorioPosto"/>
<obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoRisco" target="HsRelatorioPosto" deleteRule="Cascade" db-relationship-path="toHsRelatorioPosto"/> <obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoRisco" target="HsRelatorioPosto" deleteRule="Cascade" db-relationship-path="toHsRelatorioPosto"/>
<obj-relationship name="toHsRelatorioRisco" source="HsRelatorioPostoRisco" target="HsRelatorioRisco" deleteRule="Cascade" db-relationship-path="toHsRelatorioRisco"/> <obj-relationship name="toHsRelatorioRisco" source="HsRelatorioPostoRisco" target="HsRelatorioRisco" deleteRule="Cascade" db-relationship-path="toHsRelatorioRisco"/>
<obj-relationship name="toHsRelatorioRiscoValorQualitativo" source="HsRelatorioPostoRisco" target="HsRelatorioRiscoValorQualitativo" deleteRule="Nullify" db-relationship-path="toHsRelatorioRiscoValorQualitativo"/> <obj-relationship name="toHsRelatorioRiscoValorQualitativo" source="HsRelatorioPostoRisco" target="HsRelatorioRiscoValorQualitativo" deleteRule="Nullify" db-relationship-path="toHsRelatorioRiscoValorQualitativo"/>

@ -70,6 +70,17 @@ public class Estabelecimentos extends _Estabelecimentos implements Comparable<Es
return result; return result;
} }
@Override
public List<MarcacoesEstabelecimento> getMarcacoesEstabelecimentoArray()
{
List<MarcacoesEstabelecimento> result = super.getMarcacoesEstabelecimentoArray();
if( result != null )
{
Collections.sort( result );
}
return result;
}
@Override @Override
public int compareTo( Estabelecimentos estabelecimento ) public int compareTo( Estabelecimentos estabelecimento )
{ {

@ -2,7 +2,7 @@ package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._MarcacoesEstabelecimento; import siprp.database.cayenne.objects.auto._MarcacoesEstabelecimento;
public class MarcacoesEstabelecimento extends _MarcacoesEstabelecimento { public class MarcacoesEstabelecimento extends _MarcacoesEstabelecimento implements Comparable<MarcacoesEstabelecimento>{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -11,6 +11,20 @@ public class MarcacoesEstabelecimento extends _MarcacoesEstabelecimento {
{ {
return sdf.format( getData() ); return sdf.format( getData() );
} }
@Override
public int compareTo( MarcacoesEstabelecimento marcacao )
{
if( marcacao != null && marcacao.getData() != null )
{
return marcacao.getData().compareTo( this.getData() );
}
else
{
return -1;
}
}
} }

@ -230,5 +230,27 @@ public class HigieneSegurancaLogic
} }
} }
} }
public static boolean isProbabilidadeValida( Integer probabilidade )
{
return probabilidade != null && probabilidade > 0 && probabilidade < 17;
}
public static boolean isSeveridadeValida( Integer severidade )
{
return severidade != null && severidade > 0 && severidade < 17;
}
public static boolean isRelatorioRiscoPreenchido( HsRelatorioPostoRisco rel )
{
boolean hasQual = rel.getToHsRelatorioRiscoValorQualitativo() != null;
boolean hasQuant = false;
if( !hasQual )
{
hasQuant = HigieneSegurancaLogic.isSeveridadeValida( rel.getSeveridade() );
hasQuant &= HigieneSegurancaLogic.isProbabilidadeValida( rel.getSeveridade() );
}
return hasQual || hasQuant;
}
} }

@ -1,4 +1,4 @@
package siprp.higiene.gestao.equipamentos; package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
Loading…
Cancel
Save