diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java index 8ee7e753..cc1041a7 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java @@ -26,6 +26,7 @@ import leaf.ui.TreeTools; import siprp.database.cayenne.objects.HsEquipamentoMedico; import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico; +import siprp.logic.node.EquipamentoNode; public class AdicionarEquipamentosPanel extends JPanel { @@ -133,7 +134,7 @@ public class AdicionarEquipamentosPanel extends JPanel { 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 ) { 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() { TreePath path = tree.getSelectionPath(); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java index 3e6c8266..67671722 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -148,7 +148,7 @@ public class GerirMedidaPanel extends JPanel 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( buttonRevertRequesito, new TableLayoutConstraints(2,0) ); add( scrollRequesitos, new TableLayoutConstraints(0,1,2,1) ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java index f0339f05..fc4e94f2 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java @@ -237,8 +237,8 @@ public class GerirRiscosPanel extends JPanel if( risco != null ) { HsMedida medida = new HsMedida(); - medida.setDescription( "(medida)" ); - medida.setRequesitosLegais( "(requesitos legais)" ); + medida.setDescription( "" ); + medida.setRequesitosLegais( "" ); medida.save(); HsRiscoMedida rel = new HsRiscoMedida(); rel.setToHsRisco( risco ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AdicionarRiscosRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AdicionarRiscosRelatorioPanel.java deleted file mode 100644 index b0c48ddd..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AdicionarRiscosRelatorioPanel.java +++ /dev/null @@ -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(); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AreaRelatorioNode.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AreaRelatorioNode.java deleted file mode 100644 index 501d9c80..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AreaRelatorioNode.java +++ /dev/null @@ -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 ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java index df9d9929..d513045a 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java @@ -171,7 +171,7 @@ public class GerirMedidaRelatorioPanel extends JPanel panel.setLayout( layout ); panel.add( checkPlanoActuacao, new TableLayoutConstraints(0,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( buttonRevertRequesito, new TableLayoutConstraints(2,1) ); add( scrollRequesitos, new TableLayoutConstraints(0,2,2,2) ); @@ -189,6 +189,7 @@ public class GerirMedidaRelatorioPanel extends JPanel boolean requesitoChanged = false; if( relacao != null ) { + checkPlanoActuacao.setEnabled( true ); medidaChanged = !fieldTextMedida.getText().equals( relacao.getToHsRelatorioMedida().getDescription() ); requesitoChanged = !fieldTextRequisitosLegais.getText().equals( relacao.getToHsRelatorioMedida().getRequesitosLegais() ); } @@ -207,6 +208,7 @@ public class GerirMedidaRelatorioPanel extends JPanel buttonRevertRequesito.setEnabled( false ); fieldTextRequisitosLegais.setEnabled( false ); fieldTextMedida.setEnabled( false ); + checkPlanoActuacao.setEnabled( false ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java new file mode 100644 index 00000000..e0bc0d91 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java @@ -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(); + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java index e7bab94e..f3cb5a71 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java @@ -7,18 +7,15 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JComboBox; -import javax.swing.JComponent; +import javax.swing.JFormattedTextField; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; -import javax.swing.JTextField; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import leaf.ui.LeafButton; import leaf.ui.LeafIconButton; @@ -26,31 +23,35 @@ import siprp.database.cayenne.objects.HsRelatorioPostoRisco; import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo; import siprp.logic.HigieneSegurancaLogic; +import static com.evolute.utils.strings.UnicodeLatin1Map.*; + public class GerirValoresRiscoPanel extends JPanel implements ActionListener, CaretListener { 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_REVERT = "siprp/higiene/gestao/riscos/revert.png"; - + + public static final String VALUE_CHANGED = "VALUE_CHANGED"; + private final JRadioButton radioValorQuantitativo = new JRadioButton(); - + private final JRadioButton radioValorQualitativo = new JRadioButton(); - - private final JTextField textSeveridade = new JTextField(); - - private final JTextField textProbabilidade = new JTextField(); - + + private final JFormattedTextField textSeveridade = new JFormattedTextField(); + + private final JFormattedTextField textProbabilidade = new JFormattedTextField(); + private final JComboBox comboValorQualitativo = new JComboBox(); - + 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 HsRelatorioPostoRisco valoresRisco = null; public GerirValoresRiscoPanel() @@ -61,7 +62,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca placeComponents(); loadValoresQualitativos(); } - + private void startupListeners() { radioValorQualitativo.addActionListener( this ); @@ -85,8 +86,9 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca refresh(); } } ); + } - + private void startupComponents() { textSeveridade.setPreferredSize( new Dimension( 30, 0 ) ); @@ -96,41 +98,43 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca bg.add( radioValorQualitativo ); bg.add( radioValorQuantitativo ); } - + private void startupLayout() { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL + }, new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM + } ); layout.setVGap( 5 ); layout.setHGap( 5 ); setLayout( layout ); } - + private void placeComponents() { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM + } ); layout.setVGap( 5 ); layout.setHGap( 5 ); JPanel panel = new JPanel(); panel.setLayout( layout ); panel.add( buttonSave, new TableLayoutConstraints( 1, 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( new JLabel("Severidade"), new TableLayoutConstraints( 1, 1 ) ); + add( new JLabel( "Severidade" ), new TableLayoutConstraints( 1, 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( radioValorQualitativo, new TableLayoutConstraints( 0, 2 ) ); add( comboValorQualitativo, new TableLayoutConstraints( 1, 2, 5, 2 ) ); } - + private void loadValoresQualitativos() { comboValorQualitativo.removeAllItems(); @@ -140,7 +144,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca } } - private void refresh() + void refresh() { if( valoresRisco != null ) { @@ -149,7 +153,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca radioValorQualitativo.setSelected( qualitativo ); String severidade = (valoresRisco.getSeveridade() == null ? null : valoresRisco.getSeveridade() + ""); String probabilidade = (valoresRisco.getProbabilidade() == null ? null : valoresRisco.getProbabilidade() + ""); - textSeveridade.setText( severidade ); + textSeveridade.setText( severidade ); textProbabilidade.setText( probabilidade ); if( valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null ) { @@ -163,7 +167,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca textProbabilidade.setText( null ); } } - + private void setEnabled() { if( isEnabled() ) @@ -178,11 +182,11 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca boolean changes = false; boolean wasQual = valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null; boolean isQual = radioValorQualitativo.isSelected(); - if(!isQual) + if( !isQual ) { changes = wasQual; - if(!changes) - { + if( !changes ) + { boolean probChanged = false; boolean sevChanged = false; String prob = textProbabilidade.getText(); @@ -193,7 +197,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca } else { - probChanged = !prob.equals(valoresRisco.getProbabilidade() == null ? "" : valoresRisco.getProbabilidade() + ""); + probChanged = !prob.equals( valoresRisco.getProbabilidade() == null ? "" : valoresRisco.getProbabilidade() + "" ); } if( sev == null ) { @@ -201,7 +205,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca } else { - sevChanged = !sev.equals(valoresRisco.getSeveridade() == null ? "" : valoresRisco.getSeveridade() + "" ); + sevChanged = !sev.equals( valoresRisco.getSeveridade() == null ? "" : valoresRisco.getSeveridade() + "" ); } changes = probChanged || sevChanged; } @@ -209,8 +213,8 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca else { changes = !wasQual; - if(!changes) - { + if( !changes ) + { changes = !comboValorQualitativo.getSelectedItem().equals( valoresRisco.getToHsRelatorioRiscoValorQualitativo() ); } } @@ -229,14 +233,19 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca textSeveridade.setEnabled( false ); } } - + public void setRelatorioPostoRisco( HsRelatorioPostoRisco rel ) { - this.valoresRisco = rel; + this.valoresRisco = rel; refresh(); 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() { if( valoresRisco != null ) @@ -248,26 +257,48 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca else { valoresRisco.setToHsRelatorioRiscoValorQualitativo( null ); - Integer probabilidade = 0; - Integer severidade = 0; - try{ - probabilidade = new Integer(textProbabilidade.getText() != null ? textProbabilidade.getText() : "0" ); - } - catch (NumberFormatException e1) + Integer probabilidade = null; + Integer severidade = null; + boolean ok = true; + if( textProbabilidade.getText() != null && !textProbabilidade.getText().trim().equals( "" ) ) { - e1.printStackTrace(); - } - try{ - severidade = new Integer(textSeveridade.getText() != null ? textSeveridade.getText() : "0" ); + try + { + probabilidade = new Integer( textProbabilidade.getText() ); + } 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 ); - valoresRisco.setSeveridade( severidade ); + boolean pvalid = HigieneSegurancaLogic.isProbabilidadeValida( probabilidade ); + boolean svalid = HigieneSegurancaLogic.isSeveridadeValida( severidade ); + + valoresRisco.setProbabilidade( pvalid && svalid ? probabilidade : null ); + valoresRisco.setSeveridade( pvalid && svalid ? severidade : null ); } valoresRisco.save(); + firePropertyChange( VALUE_CHANGED, null, valoresRisco ); refresh(); setEnabled(); } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidaRelatorioNode.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidaRelatorioNode.java deleted file mode 100644 index 2ad5e344..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidaRelatorioNode.java +++ /dev/null @@ -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 ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java index f3db7a9a..9b5ff560 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -93,7 +93,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe bg.add( radioInicial ); bg.add( radioPeriodica ); 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( "Legisla" + ccedil + otilde + "es", panelLegislacao ); } @@ -294,13 +294,17 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe buttonSubmit.setEnabled( enabled ); } - public void setRelatorio( HsRelatorio relatorio ) + public void setRelatorio( HsRelatorio relatorio,boolean create ) { this.relatorio = relatorio; buttonSave.setEnabled( false ); buttonRevert.setEnabled( false ); panelEquipamentos.setRelatorio( relatorio ); panelPlano.setRelatorio( relatorio ); + if( create ) + { + panelPlano.revert(false); + } refresh(); setEnabled(); } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java index 86ee2c3c..7004a4f7 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java @@ -27,7 +27,7 @@ public class PlanoActuacaoPanel extends JPanel 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"; @@ -35,9 +35,9 @@ public class PlanoActuacaoPanel extends JPanel 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(); @@ -64,7 +64,7 @@ public class PlanoActuacaoPanel extends JPanel private void startupListeners() { - areas.addPropertyChangeListener( AdicionarAreasRelatorioPanel.SELECTION_CHANGED, new PropertyChangeListener() + areas.addPropertyChangeListener( VerAreasRelatorioPanel.SELECTION_CHANGED, new PropertyChangeListener() { @Override 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 public void propertyChange( PropertyChangeEvent evt ) @@ -107,16 +107,28 @@ public class PlanoActuacaoPanel extends JPanel @Override 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 ) { - 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 ) { HigieneSegurancaLogic.reverterRelatorio(relatorio); @@ -127,8 +139,9 @@ public class PlanoActuacaoPanel extends JPanel private void startupComponents() { - riscos.setBorder( BorderFactory.createTitledBorder( "Riscos" ) ); + riscos.setBorder( BorderFactory.createTitledBorder( "Medidas" ) ); areas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) ); + buttonRevert.setToolTipText( "Carregar dados do estabelecimento" ); } private void startupLayout() diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PostoRelatorioNode.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PostoRelatorioNode.java deleted file mode 100644 index 8fcf3e66..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PostoRelatorioNode.java +++ /dev/null @@ -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 ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java index 04809937..a035a5d8 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java @@ -5,11 +5,11 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.awt.peer.PanelPeer; import java.util.Date; import java.util.List; @@ -31,6 +31,10 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable { 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 Dimension SIZE = new Dimension( 1024, 700 ); @@ -152,7 +156,8 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable private void fillRelatorio( MarcacoesEstabelecimento visita ) { - panelRelatorio.setRelatorio( null ); + boolean carregarDadosEstabelecimento = false; + panelRelatorio.setRelatorio( null, carregarDadosEstabelecimento ); if( visita != null ) { HsRelatorio relatorio = null; @@ -173,8 +178,9 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable relatorio.setData( new Date() ); relatorio.setToHsMarcacoesEstabelecimento( visita ); relatorio.save(); + carregarDadosEstabelecimento = true; } - panelRelatorio.setRelatorio( relatorio ); + panelRelatorio.setRelatorio( relatorio, carregarDadosEstabelecimento );; } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RiscoRelatorioNode.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RiscoRelatorioNode.java deleted file mode 100644 index 455462af..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RiscoRelatorioNode.java +++ /dev/null @@ -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 ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AdicionarAreasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java similarity index 63% rename from trunk/SIPRPSoft/src/siprp/higiene/relatorio/AdicionarAreasRelatorioPanel.java rename to trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java index 661e528e..be65eb48 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/AdicionarAreasRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java @@ -3,33 +3,33 @@ package siprp.higiene.relatorio; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.Component; + 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.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorioPosto; +import siprp.database.cayenne.objects.HsRelatorioPostoRisco; 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; 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 DefaultTreeModel model = new DefaultTreeModel( root ); @@ -40,7 +40,7 @@ public class AdicionarAreasRelatorioPanel extends JPanel private HsRelatorio relatorio = null; - public AdicionarAreasRelatorioPanel() + public VerAreasRelatorioPanel() { startupComponents(); setupLayout(); @@ -50,10 +50,44 @@ public class AdicionarAreasRelatorioPanel extends JPanel 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 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() @@ -77,8 +111,8 @@ public class AdicionarAreasRelatorioPanel extends JPanel layout.setHGap( 5 ); layout.setVGap( 5 ); panel.setLayout( layout ); - panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); - panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); +// 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 ) ); @@ -101,8 +135,8 @@ public class AdicionarAreasRelatorioPanel extends JPanel private void setEnabled() { - buttonAdicionar.setEnabled( false ); - buttonRemover.setEnabled( false ); +// buttonAdicionar.setEnabled( false ); +// buttonRemover.setEnabled( false ); } public void refresh() diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/revert.png b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/revert.png new file mode 100644 index 00000000..d655eba6 Binary files /dev/null and b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/revert.png differ diff --git a/trunk/common/src/SIPRPMap.map.xml b/trunk/common/src/SIPRPMap.map.xml index 8d08e6d7..7494a342 100644 --- a/trunk/common/src/SIPRPMap.map.xml +++ b/trunk/common/src/SIPRPMap.map.xml @@ -1853,8 +1853,8 @@ - - + + diff --git a/trunk/common/src/siprp/database/cayenne/objects/Estabelecimentos.java b/trunk/common/src/siprp/database/cayenne/objects/Estabelecimentos.java index 3bd3cbe6..0e1af399 100755 --- a/trunk/common/src/siprp/database/cayenne/objects/Estabelecimentos.java +++ b/trunk/common/src/siprp/database/cayenne/objects/Estabelecimentos.java @@ -70,6 +70,17 @@ public class Estabelecimentos extends _Estabelecimentos implements Comparable getMarcacoesEstabelecimentoArray() + { + List result = super.getMarcacoesEstabelecimentoArray(); + if( result != null ) + { + Collections.sort( result ); + } + return result; + } + @Override public int compareTo( Estabelecimentos estabelecimento ) { diff --git a/trunk/common/src/siprp/database/cayenne/objects/MarcacoesEstabelecimento.java b/trunk/common/src/siprp/database/cayenne/objects/MarcacoesEstabelecimento.java index 9d4a0e69..48a5a2f8 100755 --- a/trunk/common/src/siprp/database/cayenne/objects/MarcacoesEstabelecimento.java +++ b/trunk/common/src/siprp/database/cayenne/objects/MarcacoesEstabelecimento.java @@ -2,7 +2,7 @@ package siprp.database.cayenne.objects; import siprp.database.cayenne.objects.auto._MarcacoesEstabelecimento; -public class MarcacoesEstabelecimento extends _MarcacoesEstabelecimento { +public class MarcacoesEstabelecimento extends _MarcacoesEstabelecimento implements Comparable{ private static final long serialVersionUID = 1L; @@ -11,6 +11,20 @@ public class MarcacoesEstabelecimento extends _MarcacoesEstabelecimento { { 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; + } + + } } diff --git a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java index bac32e15..bdd21c1f 100644 --- a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java @@ -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; + } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/EquipamentoNode.java b/trunk/common/src/siprp/logic/node/EquipamentoNode.java similarity index 88% rename from trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/EquipamentoNode.java rename to trunk/common/src/siprp/logic/node/EquipamentoNode.java index 9cea5660..2c1a0e0a 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/EquipamentoNode.java +++ b/trunk/common/src/siprp/logic/node/EquipamentoNode.java @@ -1,4 +1,4 @@ -package siprp.higiene.gestao.equipamentos; +package siprp.logic.node; import javax.swing.tree.DefaultMutableTreeNode;