diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java index 2c2fbd7b..37cba700 100644 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java @@ -19,6 +19,7 @@ import siprp.higiene.gestao.riscos.GerirRiscosPanel; import siprp.higiene.legislacoes.GestaoLegislacoesWindow; import siprp.higiene.mapa.MapaHigieneWindow; import siprp.higiene.marcacoes.MarcacoesHigieneWindow; +import siprp.higiene.relatorio.RelatorioHigieneSegurancaWindow; import siprp.impressaofichas.ImpressaoFichasWindow; import siprp.lembretes.LembretesWindow; import siprp.medicina.MedicinaWindow; @@ -248,20 +249,20 @@ public class SIPRPTracker extends WindowTracker return new MapaHigieneWindow(); } } ); - higieneNode.add( new DefaultMutableTreeNode( GestaoLegislacoesWindow.TITLE) ); - creators.put( GestaoLegislacoesWindow.TITLE, new WindowCreator() { + higieneNode.add( new DefaultMutableTreeNode( GestaoRelatorioWindow.TITLE ) ); + creators.put( GestaoRelatorioWindow.TITLE, new WindowCreator() { public TrackableWindow create() throws Exception { - return new GestaoLegislacoesWindow(); + return new GestaoRelatorioWindow(); } } ); - higieneNode.add( new DefaultMutableTreeNode( GestaoRelatorioWindow.TITLE ) ); - creators.put( GestaoRelatorioWindow.TITLE, new WindowCreator() { + higieneNode.add( new DefaultMutableTreeNode( RelatorioHigieneSegurancaWindow.TITLE ) ); + creators.put( RelatorioHigieneSegurancaWindow.TITLE, new WindowCreator() { public TrackableWindow create() throws Exception { - return new GestaoRelatorioWindow(); + return new RelatorioHigieneSegurancaWindow(); } } ); rootNode.add( higieneNode ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java new file mode 100644 index 00000000..3e6c8266 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -0,0 +1,235 @@ +package siprp.higiene.gestao.riscos; + +import info.clearthought.layout.TableLayout; +import info.clearthought.layout.TableLayoutConstraints; + +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; + +import leaf.ui.LeafButton; +import siprp.database.cayenne.objects.HsMedida; + +import com.evolute.utils.images.ImageException; +import com.evolute.utils.images.ImageIconLoader; + +public class GerirMedidaPanel extends JPanel +{ + + public static final String MEDIDA_CHANGED = "MEDIDA_CHANGED"; + + 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"; + + private LeafButton buttonSaveMedida; + + private LeafButton buttonRevertMedida; + + private LeafButton buttonSaveRequesito; + + private LeafButton buttonRevertRequesito; + + private final JTextArea fieldTextMedida = new JTextArea(); + + private final JScrollPane scrollMedida = new JScrollPane(fieldTextMedida); + + private final JTextArea fieldTextRequisitosLegais = new JTextArea(); + + private final JScrollPane scrollRequesitos = new JScrollPane(fieldTextRequisitosLegais); + + private HsMedida medida = null; + + public GerirMedidaPanel() + { + try + { + buttonSaveMedida = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); + buttonRevertMedida = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); + buttonSaveRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); + buttonRevertRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); + } catch( ImageException e ) + { + e.printStackTrace(); + } + startupComponents(); + startupLayout(); + placeComponents(); + setupListeners(); + } + + private void startupComponents() + { + fieldTextMedida.setWrapStyleWord( true ); + fieldTextMedida.setLineWrap( true ); + fieldTextRequisitosLegais.setWrapStyleWord( true ); + fieldTextRequisitosLegais.setLineWrap( true ); + scrollMedida.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); + scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + scrollRequesitos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); + buttonSaveMedida.setMargin( new Insets(0,0,0,0) ); + buttonSaveRequesito.setMargin( new Insets(0,0,0,0) ); + buttonRevertMedida.setMargin( new Insets(0,0,0,0) ); + buttonRevertRequesito.setMargin( new Insets(0,0,0,0) ); + } + + private void setupListeners() + { + fieldTextRequisitosLegais.addCaretListener( new CaretListener() + { + @Override + public void caretUpdate( CaretEvent e ) + { + setEnabled(); + } + } ); + fieldTextMedida.addCaretListener( new CaretListener() + { + @Override + public void caretUpdate( CaretEvent e ) + { + setEnabled(); + } + } ); + buttonSaveMedida.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + saveMedida(); + } + } ); + buttonSaveRequesito.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + saveRequesito(); + } + } ); + buttonRevertMedida.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + revertMedida(); + } + } ); + buttonRevertRequesito.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + revertRequesito(); + } + } ); + } + + private void startupLayout() + { + TableLayout layout = new TableLayout( + new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM }, + new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL } + ); + layout.setHGap( 5 ); + layout.setVGap( 5 ); + setLayout( layout ); + } + + private void placeComponents() + { + add( new JLabel("Requesitos 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) ); + add( new JLabel("Medida"), new TableLayoutConstraints(0,2) ); + add( buttonSaveMedida, new TableLayoutConstraints(1,2) ); + add( buttonRevertMedida, new TableLayoutConstraints(2,2) ); + add( scrollMedida, new TableLayoutConstraints(0,3,2,3) ); + } + + private void setEnabled() + { + boolean medidaChanged = false; + boolean requesitoChanged = false; + if( medida != null ) + { + medidaChanged = !fieldTextMedida.getText().equals( medida.getDescription() ); + requesitoChanged = !fieldTextRequisitosLegais.getText().equals( medida.getRequesitosLegais() ); + } + buttonSaveMedida.setEnabled( medidaChanged ); + buttonSaveRequesito.setEnabled( requesitoChanged ); + buttonRevertMedida.setEnabled( medidaChanged ); + buttonRevertRequesito.setEnabled( requesitoChanged ); + } + + private void saveMedida() + { + if( medida != null ) + { + medida.setDescription( fieldTextMedida.getText() ); + medida.save(); + refresh(); + } + setEnabled(); + } + + private void saveRequesito() + { + if( medida != null ) + { + medida.setRequesitosLegais(fieldTextRequisitosLegais.getText() ); + medida.save(); + refresh(); + } + setEnabled(); + } + + private void revertMedida() + { + if( medida != null ) + { + fieldTextMedida.setText( medida.getDescription() ); + } + setEnabled(); + } + + private void revertRequesito() + { + if( medida != null ) + { + fieldTextRequisitosLegais.setText( medida.getRequesitosLegais() ); + } + setEnabled(); + } + + private void refresh() + { + firePropertyChange( MEDIDA_CHANGED, null, medida ); + } + + public void setMedida( HsMedida medida ) + { + this.medida = medida; + fieldTextMedida.setText( medida == null ? null : medida.getDescription() ); + fieldTextRequisitosLegais.setText( medida == null ? null : medida.getRequesitosLegais() ); + setEnabled(); + } + + public HsMedida getMedida() + { + return this.medida; + } + + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java index b94b0ec1..f0339f05 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java @@ -8,19 +8,16 @@ import info.clearthought.layout.TableLayoutConstraints; import java.awt.CardLayout; import java.awt.Dimension; import java.awt.GridLayout; -import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import javax.swing.BorderFactory; -import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTextArea; import javax.swing.JTree; -import javax.swing.event.CaretEvent; -import javax.swing.event.CaretListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; @@ -36,18 +33,11 @@ import siprp.database.cayenne.objects.HsRiscoMedida; import siprp.database.cayenne.objects.HsRiscoTema; import siprp.logic.HigieneSegurancaLogic; -import com.evolute.utils.images.ImageException; -import com.evolute.utils.images.ImageIconLoader; - public class GerirRiscosPanel extends JPanel { 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"; - private static final String PANEL_TEMA = "PANEL_TEMA"; private static final String PANEL_RISCO = "PANEL_RISCO"; @@ -64,7 +54,7 @@ public class GerirRiscosPanel extends JPanel private final JPanel panelDataRisco = new JPanel(); - private final JPanel panelDataMedida = new JPanel(); + private final GerirMedidaPanel panelDataMedida = new GerirMedidaPanel(); private final LeafButton buttonTemaCriar = new LeafButton( "Criar" ); @@ -78,22 +68,6 @@ public class GerirRiscosPanel extends JPanel private final LeafButton buttonMedidaRemover = new LeafButton( "Remover" ); - private LeafButton buttonSaveMedida; - - private LeafButton buttonRevertMedida; - - private LeafButton buttonSaveRequesito; - - private LeafButton buttonRevertRequesito; - - private final JTextArea fieldTextMedida = new JTextArea(); - - private final JScrollPane scrollMedida = new JScrollPane(fieldTextMedida); - - private final JTextArea fieldTextRequisitosLegais = new JTextArea(); - - private final JScrollPane scrollRequesitos = new JScrollPane(fieldTextRequisitosLegais); - private final DefaultMutableTreeNode root = new DefaultMutableTreeNode(); private final DefaultTreeModel model = new DefaultTreeModel( root ); @@ -106,16 +80,6 @@ public class GerirRiscosPanel extends JPanel public GerirRiscosPanel() { - try - { - buttonSaveMedida = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); - buttonRevertMedida = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); - buttonSaveRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); - buttonRevertRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); - } catch( ImageException e ) - { - e.printStackTrace(); - } startupComponents(); startupLayout(); placeComponents(); @@ -181,96 +145,17 @@ public class GerirRiscosPanel extends JPanel selectCard(); } }); - fieldTextRequisitosLegais.addCaretListener( new CaretListener() - { - @Override - public void caretUpdate( CaretEvent e ) - { - enableEditButtons(); - } - } ); - fieldTextMedida.addCaretListener( new CaretListener() + panelDataMedida.addPropertyChangeListener( GerirMedidaPanel.MEDIDA_CHANGED, new PropertyChangeListener() { @Override - public void caretUpdate( CaretEvent e ) + public void propertyChange( PropertyChangeEvent evt ) { - enableEditButtons(); - } - } ); - buttonSaveMedida.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - saveMedida(); - } - } ); - buttonSaveRequesito.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - saveRequesito(); - } - } ); - buttonRevertMedida.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - revertMedida(); - } - } ); - buttonRevertRequesito.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - revertRequesito(); + if( evt.getNewValue() != null ) + { + refresh(); + } } - } ); - } - - private void saveMedida() - { - HsRiscoMedida rel = getSelectedMedida(); - if( rel != null ) - { - rel.getToHsMedida().setDescription( fieldTextMedida.getText() ); - rel.save(); - } - enableEditButtons(); - } - - private void saveRequesito() - { - HsRiscoMedida rel = getSelectedMedida(); - if( rel != null ) - { - rel.getToHsMedida().setRequesitosLegais(fieldTextRequisitosLegais.getText() ); - rel.save(); - } - enableEditButtons(); - } - - private void revertMedida() - { - HsRiscoMedida rel = getSelectedMedida(); - if( rel != null ) - { - fieldTextMedida.setText( rel.getToHsMedida().getDescription() ); - } - enableEditButtons(); - } - - private void revertRequesito() - { - HsRiscoMedida rel = getSelectedMedida(); - if( rel != null ) - { - fieldTextRequisitosLegais.setText( rel.getToHsMedida().getRequesitosLegais() ); - } - enableEditButtons(); + }); } private void criarTema() @@ -409,18 +294,6 @@ public class GerirRiscosPanel extends JPanel panelTree.setPreferredSize( new Dimension( 300, 0 ) ); tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); - fieldTextMedida.setWrapStyleWord( true ); - fieldTextMedida.setLineWrap( true ); - fieldTextRequisitosLegais.setWrapStyleWord( true ); - fieldTextRequisitosLegais.setLineWrap( true ); - scrollMedida.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollRequesitos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - buttonSaveMedida.setMargin( new Insets(0,0,0,0) ); - buttonSaveRequesito.setMargin( new Insets(0,0,0,0) ); - buttonRevertMedida.setMargin( new Insets(0,0,0,0) ); - buttonRevertRequesito.setMargin( new Insets(0,0,0,0) ); } private void setEnabled() @@ -433,21 +306,6 @@ public class GerirRiscosPanel extends JPanel buttonMedidaRemover.setEnabled( medida != null ); buttonRiscoRemover.setEnabled( risco != null ); buttonTemaRemover.setEnabled( tema != null ); - enableEditButtons(); - } - - private void enableEditButtons() - { - HsRiscoMedida rel = getSelectedMedida(); - if( rel != null ) - { - boolean medidaChanged = !fieldTextMedida.getText().equals( rel.getToHsMedida().getDescription() ); - boolean requesitoChanged = !fieldTextRequisitosLegais.getText().equals( rel.getToHsMedida().getRequesitosLegais() ); - buttonSaveMedida.setEnabled( medidaChanged ); - buttonSaveRequesito.setEnabled( requesitoChanged ); - buttonRevertMedida.setEnabled( medidaChanged ); - buttonRevertRequesito.setEnabled( requesitoChanged ); - } } private void startupLayout() @@ -492,14 +350,6 @@ public class GerirRiscosPanel extends JPanel layout.setVGap( 5 ); panelDataRisco.setLayout( layout ); - layout = new TableLayout( - new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL } - ); - layout.setHGap( 5 ); - layout.setVGap( 5 ); - panelDataMedida.setLayout( layout ); - panelData.setLayout( cardLayout ); } @@ -526,15 +376,6 @@ public class GerirRiscosPanel extends JPanel panelTree.add( scroll, new TableLayoutConstraints( 0, 0 ) ); - panelDataMedida.add( new JLabel("Requesitos legais"), new TableLayoutConstraints(0,0) ); - panelDataMedida.add( buttonSaveRequesito, new TableLayoutConstraints(1,0) ); - panelDataMedida.add( buttonRevertRequesito, new TableLayoutConstraints(2,0) ); - panelDataMedida.add( scrollRequesitos, new TableLayoutConstraints(0,1,2,1) ); - panelDataMedida.add( new JLabel("Medida"), new TableLayoutConstraints(0,2) ); - panelDataMedida.add( buttonSaveMedida, new TableLayoutConstraints(1,2) ); - panelDataMedida.add( buttonRevertMedida, new TableLayoutConstraints(2,2) ); - panelDataMedida.add( scrollMedida, new TableLayoutConstraints(0,3,2,3) ); - panelData.add( panelDataTema, PANEL_TEMA ); panelData.add( panelDataRisco, PANEL_RISCO ); panelData.add( panelDataMedida, PANEL_MEDIDA ); @@ -561,12 +402,10 @@ public class GerirRiscosPanel extends JPanel else if( medida != null ) { cardLayout.show( panelData, PANEL_MEDIDA ); - fieldTextMedida.setText( medida.getToHsMedida().getDescription() ); - fieldTextRequisitosLegais.setText( medida.getToHsMedida().getRequesitosLegais() ); + panelDataMedida.setMedida( medida.getToHsMedida() ); } } - private void refresh() { root.removeAllChildren(); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/legislacao/GestaoDadosRelatorioWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/legislacao/GestaoDadosRelatorioWindow.java deleted file mode 100644 index 324c422d..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/legislacao/GestaoDadosRelatorioWindow.java +++ /dev/null @@ -1,8 +0,0 @@ -package siprp.higiene.legislacao; - -import javax.swing.JFrame; - -public class GestaoDadosRelatorioWindow extends JFrame -{ - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java new file mode 100644 index 00000000..97603ba2 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -0,0 +1,151 @@ +package siprp.higiene.relatorio; + +import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; +import static com.evolute.utils.strings.UnicodeLatin1Map.eacute; +import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; +import static com.evolute.utils.strings.UnicodeLatin1Map.otilde; +import info.clearthought.layout.TableLayout; +import info.clearthought.layout.TableLayoutConstraints; + +import java.awt.Dimension; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; + +import leaf.ui.LeafIconButton; +import siprp.database.cayenne.objects.HsRelatorio; +import siprp.higiene.gestao.equipamentos.AdicionarEquipamentosPanel; + +import com.evolute.utils.ui.calendar.JCalendarPanel; + +public class PanelRelatorio extends JPanel +{ + + 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"; + + private final JCalendarPanel dataRelatorio = new JCalendarPanel( null ); + + private final JRadioButton radioInicial = new JRadioButton( "Inicial" ); + private final JRadioButton radioPeriodica = new JRadioButton( "Peri" + oacute + "dica" ); + + private final JTextField fieldTecnico = new JTextField(); + + private final JPanel panelAcompanhantes = new JPanel(); + + private final JTextField fieldNome1 = new JTextField(); + private final JTextField fieldNome2 = new JTextField(); + private final JTextField fieldNome3 = new JTextField(); + + private final JTextField fieldFuncao1 = new JTextField(); + private final JTextField fieldFuncao2 = new JTextField(); + private final JTextField fieldFuncao3 = new JTextField(); + + private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE ); + private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT ); + + private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel(); + + private final JTabbedPane tabs = new JTabbedPane(); + + private final PlanoActuacaoPanel panelPlano = new PlanoActuacaoPanel(); + + private final RelatorioLegislacoesPanel panelLegislacao = new RelatorioLegislacoesPanel(); + + private HsRelatorio relatorio = null; + + public PanelRelatorio() + { + setupListeners(); + startupComponents(); + startupLayout(); + placeComponents(); + } + + private void startupComponents() + { + dataRelatorio.setPreferredSize( new Dimension( 150, 0 ) ); + panelEquipamentos.setPreferredSize( new Dimension( 200, 0 ) ); + fieldFuncao1.setPreferredSize( new Dimension( 100, 0 ) ); + ButtonGroup bg = new ButtonGroup(); + bg.add( radioInicial ); + bg.add( radioPeriodica ); + panelAcompanhantes.setBorder( BorderFactory.createTitledBorder( "Pessoas que acompanharam" ) ); + tabs.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano ); + tabs.addTab( "Legisla" + ccedil + otilde + "es", panelLegislacao ); + } + + private void startupLayout() + { + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL + } ); + layout.setVGap( 5 ); + layout.setHGap( 5 ); + setLayout( layout ); + + layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED + }, new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM + } ); + layout.setVGap( 5 ); + layout.setHGap( 5 ); + panelAcompanhantes.setLayout( layout ); + } + + private void placeComponents() + { + panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 0 ) ); + panelAcompanhantes.add( fieldNome1, new TableLayoutConstraints( 1, 0 ) ); + panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 0 ) ); + panelAcompanhantes.add( fieldFuncao1, new TableLayoutConstraints( 3, 0 ) ); + panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 1 ) ); + panelAcompanhantes.add( fieldNome2, new TableLayoutConstraints( 1, 1 ) ); + panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 1 ) ); + panelAcompanhantes.add( fieldFuncao2, new TableLayoutConstraints( 3, 1 ) ); + panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 2 ) ); + panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) ); + panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) ); + panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) ); + add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 0 ) ); + add( dataRelatorio, new TableLayoutConstraints( 1, 0 ) ); + add( new JLabel( "Avalia" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 0 ) ); + add( radioInicial, new TableLayoutConstraints( 3, 0 ) ); + add( radioPeriodica, new TableLayoutConstraints( 4, 0 ) ); + add( buttonSave, new TableLayoutConstraints( 6, 0 ) ); + add( buttonRevert, new TableLayoutConstraints( 7, 0 ) ); + add( new JLabel( "T" + eacute + "cnico de H.S." ), new TableLayoutConstraints( 0, 1 ) ); + add( fieldTecnico, new TableLayoutConstraints( 1, 1, 4, 1 ) ); + add( panelEquipamentos, new TableLayoutConstraints( 5, 1, 7, 2 ) ); + add( panelAcompanhantes, new TableLayoutConstraints( 0, 2, 4, 2 ) ); + add( tabs, new TableLayoutConstraints( 0, 3, 7, 3 ) ); + } + + private void setupListeners() + { + + } + + public void setRelatorio( HsRelatorio relatorio ) + { + this.relatorio = relatorio; + refresh(); + } + + private void refresh() + { + // TODO + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java new file mode 100644 index 00000000..32c2ca59 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java @@ -0,0 +1,38 @@ +package siprp.higiene.relatorio; + +import javax.swing.JPanel; + +public class PlanoActuacaoPanel extends JPanel +{ + + private static final long serialVersionUID = 1L; + + public PlanoActuacaoPanel() + { + startupListeners(); + startupComponents(); + startupLayout(); + placeComponents(); + } + + private void startupListeners() + { + + } + + private void startupComponents() + { + + } + + private void startupLayout() + { + + } + + private void placeComponents() + { + + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java index b9d9790e..c96a78aa 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java @@ -1,56 +1,30 @@ package siprp.higiene.relatorio; -import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.Container; import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.Date; import java.util.List; -import java.util.Vector; import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.Estabelecimentos; -import siprp.database.cayenne.objects.HsArea; -import siprp.database.cayenne.objects.HsMedida; -import siprp.database.cayenne.objects.HsPosto; -import siprp.database.cayenne.objects.HsPostoEstabelecimento; -import siprp.database.cayenne.objects.HsPostoMedida; -import siprp.database.cayenne.objects.HsPostoRisco; import siprp.database.cayenne.objects.HsRelatorio; -import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo; -import siprp.database.cayenne.objects.HsRisco; -import siprp.database.cayenne.objects.HsRiscoMedida; import siprp.database.cayenne.objects.MarcacoesEstabelecimento; -import siprp.database.cayenne.providers.MedicinaDAO; -import siprp.database.cayenne.providers.PlanoActuacaoDAO; +import siprp.logic.HigieneSegurancaLogic; -import com.evolute.utils.tables.VectorTableModel; import com.evolute.utils.tracker.TrackableWindow; -import com.evolute.utils.ui.calendar.JCalendarPanel; public class RelatorioHigieneSegurancaWindow extends JFrame implements TrackableWindow { @@ -64,658 +38,143 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable private final JComboBox comboEstabelecimentos = new JComboBox(); - private final VectorTableModel modelVisitas = new VectorTableModel( new String[]{ "Data" } ); + private final JComboBox comboVisitas = new JComboBox(); - private final JTable tableVisitas = new JTable( modelVisitas ); - - private final JScrollPane scrollVisitas = new JScrollPane( tableVisitas ); - - private final JButton buttonCriarRelatorio = new JButton("Criar Relat"+oacute+"rio"); - - private final JPanel panelRelatorio = new JPanel(); - - private final JCalendarPanel dateRelatorio = new JCalendarPanel( this ); - - private final JComboBox comboArea = new JComboBox(); - - private final JComboBox comboPosto = new JComboBox(); - - private final JPanel panelRiscos = new JPanel(); - - private final VectorTableModel modelRiscos = new VectorTableModel( new String[]{ "Riscos" } ); - - private final JTable tableRiscos = new JTable( modelRiscos ); - - private final JScrollPane scrollRiscos = new JScrollPane( tableRiscos ); - - private final JPanel panelRiscoValores = new JPanel(); - - 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 JComboBox comboValorQualitativo = new JComboBox(); - - private final JCheckBox checkPlanoActuacao = new JCheckBox("Plano de actua" + ccedil + atilde + "o" ); - - private final JPanel panelMedidas = new JPanel(); - - private final VectorTableModel modelMedidas = new VectorTableModel( new String[]{ "Medidas" } ); - - private final JTable tableMedidas = new JTable( modelMedidas ); - - private final JScrollPane scrollMedidas = new JScrollPane( tableMedidas ); - - private final JTextArea textMedida = new JTextArea(); - - private final JTextArea textRequisitosLegais = new JTextArea(); - - private final JButton buttonMedidaAdd = new JButton("Adicionar"); - - private final JButton buttonMedidaRemove = new JButton("Remover"); - - private final JButton buttonSubmeterRelatorio = new JButton( "Submeter Plano de Actua" + ccedil + atilde + "o" ); - - private final ItemListener listenerComboEmpresas = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedEmpresa(); - } - }; - - private final ItemListener listenerComboEstabelecimentos = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedEstabelecimento(); - } - }; - - private final ItemListener listenerComboArea = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedArea(); - } - }; - - private final ItemListener listenerComboPosto = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedPosto(); - } - }; - - private final ItemListener listenerComboValorQualitativo = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedValorQualitativo(); - } - }; - - private final PlanoActuacaoDAO provider = new PlanoActuacaoDAO(); + private final PanelRelatorio panelRelatorio = new PanelRelatorio(); public RelatorioHigieneSegurancaWindow() { + setupListeners(); startupComponents(); startupLayout(); placeComponents(); - setupListeners(); + setLocationRelativeTo( null ); setTitle( TITLE ); setSize( SIZE ); - loadEmpresas(); - loadValoresQualitativos(); } private void startupComponents() { - scrollMedidas.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollMedidas.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - scrollMedidas.setPreferredSize( new Dimension( 150, 0 ) ); - scrollRiscos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollRiscos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - scrollRiscos.setPreferredSize( new Dimension( 300, 0 ) ); - scrollVisitas.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollVisitas.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - scrollVisitas.setPreferredSize( new Dimension( 200, 0 ) ); panelRelatorio.setBorder( BorderFactory.createTitledBorder( "Relat" + oacute + "rio" ) ); - panelRiscoValores.setBorder( BorderFactory.createTitledBorder( "Valores" ) ); - panelRiscos.setBorder( BorderFactory.createEtchedBorder() ); - panelMedidas.setBorder( BorderFactory.createEtchedBorder() ); - dateRelatorio.setPreferredSize( new Dimension( 150, 0 ) ); - textSeveridade.setPreferredSize( new Dimension( 30, 0 ) ); - textProbabilidade.setPreferredSize( new Dimension( 30, 0 ) ); - tableVisitas.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - tableRiscos.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - tableMedidas.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - ButtonGroup bg = new ButtonGroup(); - bg.add( radioValorQualitativo ); - bg.add( radioValorQuantitativo ); - } - - private void disableAndClearRelatorio( ) - { - dateRelatorio.setEnabled( false ); - dateRelatorio.clear(); - comboArea.setEnabled( false ); - comboPosto.setEnabled( false ); - buttonSubmeterRelatorio.setEnabled( false ); - disableAndClearRisco(); - disableAndClearMedida(); - } - - private void disableAndClearRisco() - { - modelRiscos.clearAll(); - radioValorQualitativo.setEnabled( false ); - radioValorQualitativo.setSelected( false ); - radioValorQuantitativo.setEnabled( false ); - radioValorQuantitativo.setSelected( false ); - textSeveridade.setEnabled( false ); - textSeveridade.setText( "" ); - textProbabilidade.setEnabled( false ); - textProbabilidade.setText( "" ); - comboValorQualitativo.setEnabled( false ); - checkPlanoActuacao.setEnabled( false ); - } - - private void disableAndClearMedida() - { - modelMedidas.clearAll(); - textMedida.setEnabled( false ); - textMedida.setText( "" ); - textRequisitosLegais.setEnabled( false ); - textRequisitosLegais.setText( "" ); - buttonMedidaAdd.setEnabled( false ); - buttonMedidaRemove.setEnabled( false ); + for( Empresas empresa : HigieneSegurancaLogic.getAllEmpresas()) + { + comboEmpresas.addItem( empresa ); + } } private void startupLayout() { TableLayout layout = new TableLayout( - new double[]{ TableLayout.PREFERRED, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - getContentPane().setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - panelRelatorio.setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.PREFERRED, TableLayout.FILL }, + new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL }, new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } ); layout.setVGap( 5 ); layout.setHGap( 5 ); - panelRiscos.setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.PREFERRED }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - panelRiscoValores.setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - panelMedidas.setLayout( layout ); - + getContentPane().setLayout( layout ); } private void placeComponents() { - - panelRiscoValores.add( radioValorQuantitativo, new TableLayoutConstraints( 0, 0 ) ); - panelRiscoValores.add( new JLabel("Severidade"), new TableLayoutConstraints( 1, 0 ) ); - panelRiscoValores.add( textSeveridade, new TableLayoutConstraints( 2, 0 ) ); - panelRiscoValores.add( new JLabel("Probabilidade"), new TableLayoutConstraints( 3, 0 ) ); - panelRiscoValores.add( textProbabilidade, new TableLayoutConstraints( 4, 0 ) ); - panelRiscoValores.add( radioValorQualitativo, new TableLayoutConstraints( 0, 1 ) ); - panelRiscoValores.add( comboValorQualitativo, new TableLayoutConstraints( 1, 1, 4, 1 ) ); - - panelRiscos.add( panelRiscoValores, new TableLayoutConstraints( 1, 0 ) ); - panelRiscos.add( checkPlanoActuacao, new TableLayoutConstraints( 1, 1 ) ); - panelRiscos.add( scrollRiscos, new TableLayoutConstraints( 0, 0, 0, 2 ) ); - - panelMedidas.add( scrollMedidas, new TableLayoutConstraints( 0, 0, 2, 3 ) ); - panelMedidas.add( buttonMedidaAdd, new TableLayoutConstraints( 0, 4 ) ); - panelMedidas.add( buttonMedidaRemove, new TableLayoutConstraints( 1, 4 ) ); - panelMedidas.add( new JLabel("Medidas"), new TableLayoutConstraints( 3, 0 ) ); - panelMedidas.add( textMedida, new TableLayoutConstraints( 3, 1 ) ); - panelMedidas.add( new JLabel("Requisitos Legais"), new TableLayoutConstraints( 3, 2 ) ); - panelMedidas.add( textRequisitosLegais, new TableLayoutConstraints( 3, 3 ) ); - - panelRelatorio.add( new JLabel("Data") , new TableLayoutConstraints( 0, 0 ) ); - panelRelatorio.add( dateRelatorio , new TableLayoutConstraints( 1, 0 ) ); - panelRelatorio.add( new JLabel("Areas") , new TableLayoutConstraints( 0, 1 ) ); - panelRelatorio.add( comboArea, new TableLayoutConstraints( 1, 1, 2, 1 ) ); - panelRelatorio.add( new JLabel("Postos de Trabalho") , new TableLayoutConstraints( 0, 2 ) ); - panelRelatorio.add( comboPosto, new TableLayoutConstraints( 1, 2, 2, 2 ) ); - panelRelatorio.add( buttonSubmeterRelatorio, new TableLayoutConstraints( 3, 0, 3, 2 ) ); - panelRelatorio.add( panelRiscos , new TableLayoutConstraints( 0, 3, 3, 3 ) ); - panelRelatorio.add( panelMedidas , new TableLayoutConstraints( 0, 4, 3, 4 ) ); - - getContentPane().add( new JLabel("Empresa"), new TableLayoutConstraints( 0, 0, 1, 0 ) ); - getContentPane().add( comboEmpresas, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - getContentPane().add( new JLabel("Estabelecimento"), new TableLayoutConstraints( 0, 2, 1, 2 ) ); - getContentPane().add( comboEstabelecimentos, new TableLayoutConstraints( 0, 3, 1, 3 ) ); - getContentPane().add( scrollVisitas, new TableLayoutConstraints( 0, 4 ) ); - getContentPane().add( buttonCriarRelatorio, new TableLayoutConstraints( 0, 5 ) ); - getContentPane().add( panelRelatorio, new TableLayoutConstraints( 1, 4, 1, 5 ) ); + Container pane = getContentPane(); + pane.add( new JLabel("Empresa"), new TableLayoutConstraints( 0, 0 ) ); + pane.add( comboEmpresas, new TableLayoutConstraints( 1, 0, 3, 0 ) ); + pane.add( new JLabel("Estabelecimento"), new TableLayoutConstraints( 0, 1 ) ); + pane.add( comboEstabelecimentos, new TableLayoutConstraints( 1, 1 ) ); + pane.add( new JLabel("Visita"), new TableLayoutConstraints( 2, 1 ) ); + pane.add( comboVisitas, new TableLayoutConstraints( 3, 1 ) ); + pane.add( panelRelatorio, new TableLayoutConstraints(0,2,3,2)); } private void setupListeners() { - comboEmpresas.addItemListener( listenerComboEmpresas ); - comboEstabelecimentos.addItemListener( listenerComboEstabelecimentos ); - comboArea.addItemListener( listenerComboArea ); - comboPosto.addItemListener( listenerComboPosto ); - comboValorQualitativo.addItemListener( listenerComboValorQualitativo ); - tableVisitas.getSelectionModel().addListSelectionListener( new ListSelectionListener() - { - @Override - public void valueChanged( ListSelectionEvent e ) - { - if( e.getValueIsAdjusting() && tableVisitas.getSelectedRowCount() > 0 ) - { - selectedVisita(); - } - } - } ); - tableRiscos.getSelectionModel().addListSelectionListener( new ListSelectionListener() + comboEmpresas.addItemListener( new ItemListener() { @Override - public void valueChanged( ListSelectionEvent e ) + public void itemStateChanged( ItemEvent e ) { - if( e.getValueIsAdjusting() ) + if( e.getStateChange() == ItemEvent.SELECTED ) { - selectedRisco(); + fillEstabelecimentos( (Empresas) e.getItem() ); } } } ); - tableMedidas.getSelectionModel().addListSelectionListener( new ListSelectionListener() + comboEstabelecimentos.addItemListener( new ItemListener() { @Override - public void valueChanged( ListSelectionEvent e ) + public void itemStateChanged( ItemEvent e ) { - if( e.getValueIsAdjusting() ) + if( e.getStateChange() == ItemEvent.SELECTED ) { - selectedMedida(); + fillVisitas( (Estabelecimentos) e.getItem() ); } } } ); - buttonCriarRelatorio.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - criarRelatorio(); - } - } ); - radioValorQuantitativo.addItemListener( new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedRadioQuantitativo( ); - } - } ); - radioValorQualitativo.addItemListener( new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedRadioQualitativo( ); - } - } ); - checkPlanoActuacao.addItemListener( new ItemListener() + comboVisitas.addItemListener( new ItemListener() { @Override public void itemStateChanged( ItemEvent e ) { - selectedPlanoActuacao( ); - } - } ); - } - - private void criarRelatorio() - { - MarcacoesEstabelecimento visita = getSelectedVisita(); - HsRelatorio relatorio = provider.criarRelatorioForVisita( visita ); - if( relatorio != null ) - { - fillRelatorio( relatorio ); - } - } - - private HsRisco getSelectedRisco() - { - int selected = tableRiscos.getSelectedRow(); - return selected > -1 ? modelRiscos.getRowAt( selected ) : null; - } - - private HsPosto getSelectedPosto() - { - return (HsPosto) comboPosto.getSelectedItem(); - } - - private void selectedPlanoActuacao() - { - HsRisco risco = getSelectedRisco(); - HsPosto posto = getSelectedPosto(); - if( risco != null && posto != null ) - { - HsPostoRisco valores = getValores( risco, posto ); - if( valores == null ) - { - valores = provider.createValoresFor( risco, posto ); - } - valores.setIsPlanoActuacao( checkPlanoActuacao.isSelected() ? "y" : "n" ); - provider.commit(); - } - } - - private void selectedEmpresa() - { - disableAndClearRelatorio( ); - buttonCriarRelatorio.setEnabled( false ); - tableVisitas.setEnabled( false ); - modelVisitas.clearAll(); - Empresas empresa = (Empresas) comboEmpresas.getSelectedItem(); - loadEstabelecimentos( empresa ); - if( empresa == null ) - { - comboEstabelecimentos.setEnabled( false ); - } - } - - private void selectedEstabelecimento() - { - disableAndClearRelatorio( ); - modelVisitas.clearAll(); - buttonCriarRelatorio.setEnabled( false ); - Estabelecimentos estabelecimento = (Estabelecimentos) comboEstabelecimentos.getSelectedItem(); - if( estabelecimento != null ) - { - List marcacoes = estabelecimento.getMarcacoesEstabelecimentoArray(); - Vector filteredMarcacoes = new Vector(); - for( MarcacoesEstabelecimento marcacao : marcacoes ) - { - if( "y".equals( marcacao.getRealizada() ) ) + if( e.getStateChange() == ItemEvent.SELECTED ) { - filteredMarcacoes.add( marcacao ); + fillRelatorio( (MarcacoesEstabelecimento) e.getItem() ); } } - modelVisitas.setValues( filteredMarcacoes ); - tableVisitas.setEnabled( true ); - } - } - - private void selectedArea() - { - disableAndClearRisco(); - disableAndClearMedida(); - HsArea area = (HsArea) comboArea.getSelectedItem(); - fillPostos( (Estabelecimentos) comboEstabelecimentos.getSelectedItem(), area ); - comboPosto.setEnabled( area != null ); - } - - private void selectedPosto() - { - modelRiscos.clearAll(); - HsPosto posto = (HsPosto) comboPosto.getSelectedItem(); - if( posto != null ) - { - Vector riscos = new Vector(); - for( HsPostoMedida rel : posto.getHsPostoMedidaArray() ) - { - for( HsRiscoMedida medidaRelRisco : rel.getToHsMedida().getHsRiscoMedidaArray() ) - { - riscos.add( medidaRelRisco.getToHsRisco() ); - } - } - modelRiscos.setValues( riscos ); - } - } - - private void selectedRadioQuantitativo() - { - textProbabilidade.setEnabled( true ) ; - textSeveridade.setEnabled( true ); - comboValorQualitativo.setEnabled( false ); - } - - private void selectedRadioQualitativo() - { - textProbabilidade.setEnabled( false ); - textSeveridade.setEnabled( false ); - comboValorQualitativo.setEnabled( true ); - } - - private void selectedValorQualitativo() - { - - } - - private void selectedRisco() - { - disableAndClearMedida(); - int selected = tableRiscos.getSelectedRow(); - HsRisco risco = selected > -1 ? modelRiscos.getRowAt( selected ) : null; - checkPlanoActuacao.setEnabled( risco != null ); - radioValorQualitativo.setEnabled( risco != null ); - radioValorQuantitativo.setEnabled( risco != null ); - fillRisco( risco, (HsPosto) comboPosto.getSelectedItem() ); - } - - private void selectedMedida() - { - int selected = tableMedidas.getSelectedRow(); - HsMedida medida = selected > -1 ? modelMedidas.getRowAt( selected ) : null; - textMedida.setEnabled( medida != null ); - textRequisitosLegais.setEnabled( medida != null ); - fillMedida( medida ); - } - - private MarcacoesEstabelecimento getSelectedVisita() - { - MarcacoesEstabelecimento result = null; - int row = tableVisitas.getSelectedRow(); - if( row > -1 ) - { - result = modelVisitas.getRowAt( row ); - } - return result; + } ); } - private void selectedVisita() + private void fillEstabelecimentos( Empresas empresa ) { - disableAndClearRelatorio( ); - MarcacoesEstabelecimento visita = getSelectedVisita(); - List relatorios = visita.getHsRelatorioArray(); - HsRelatorio relatorio = null; - for( HsRelatorio current : relatorios ) + comboEstabelecimentos.removeAllItems(); + if( empresa != null ) { - if( current.getDeletedDate() == null) + for( Estabelecimentos estabelecimento : empresa.getEstabelecimentosArray() ) { - relatorio = current; - break; + comboEstabelecimentos.addItem( estabelecimento ); } } - if( relatorio == null ) - { - buttonCriarRelatorio.setEnabled( true ); - } - else - { - fillRelatorio( relatorio ); - buttonCriarRelatorio.setEnabled( false ); - } - } - - private void fillRelatorio( HsRelatorio relatorio ) - { - boolean submetido = relatorio.getIsSubmetido() != null; - dateRelatorio.setEnabled( !submetido ); - dateRelatorio.setDate( relatorio.getData() ); - buttonSubmeterRelatorio.setEnabled( !submetido ); - comboArea.setEnabled( true ); - fillAreas( relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos() ); } - private void fillAreas( Estabelecimentos estabelecimento ) + private void fillVisitas( Estabelecimentos estabelecimento ) { - comboArea.removeAllItems(); + comboVisitas.removeAllItems(); if( estabelecimento != null ) { - for( HsArea area : new Vector( estabelecimento.getToEmpresas().getHsAreaArray() ) ) - { - comboArea.addItem( area ); - } - } - } - - private void fillPostos( Estabelecimentos estabelecimento, HsArea area ) - { - comboPosto.removeAllItems(); - if( estabelecimento != null && area != null ) - { - for( HsPostoEstabelecimento rel : estabelecimento.getHsPostoEstabelecimentoArray() ) + for( MarcacoesEstabelecimento visita : estabelecimento.getMarcacoesEstabelecimentoArray() ) { - if( area.getHsPostoArray().contains( rel.getToHsPosto() ) ) + if( "y".equals( visita.getRealizada() ) ) { - comboPosto.addItem( rel.getToHsPosto() ); + comboVisitas.addItem( visita ); } } } } - private HsPostoRisco getValores( HsRisco risco, HsPosto posto ) + private void fillRelatorio( MarcacoesEstabelecimento visita ) { - HsPostoRisco result = null; - if( risco != null && posto != null ) + panelRelatorio.setRelatorio( null ); + if( visita != null ) { - for( HsPostoRisco valores : risco.getHsPostoRiscoArray() ) + HsRelatorio relatorio = null; + List relatorios = visita.getHsRelatorioArray(); + Date data = null; + for( HsRelatorio current : relatorios ) { - if( valores.getToHsPosto().equals( posto ) ) + boolean newest = data == null ? true : (data.before( current.getData() ) ); + if( newest ) { - result = valores; - break; + data = current.getData(); + relatorio = current; } } - } - return result; - } - - private void fillRisco( HsRisco risco, HsPosto posto ) - { - modelMedidas.clearAll(); - textProbabilidade.setText( "" ); - textSeveridade.setText( "" ); - checkPlanoActuacao.setSelected( false ); - radioValorQuantitativo.setSelected( true ); - if( risco != null && posto != null ) - { - HsPostoRisco valores = getValores( risco, posto ); - if( valores != null ) + if( relatorio == null ) { - if( valores.getToHsRelatorioRiscoValorQualitativo() != null ) - { - radioValorQualitativo.setSelected( true ); - } - else - { - radioValorQuantitativo.setSelected( true ); - textProbabilidade.setText( valores.getProbabilidade() != null ? valores.getProbabilidade() + "" : "" ); - textSeveridade.setText( valores.getSeveridade() != null ? valores.getSeveridade() + "" : "" ); - checkPlanoActuacao.setSelected( "y".equals( valores.getIsPlanoActuacao() ) ); - } - } - Vector medidas = new Vector(); - for( HsPostoMedida relPostoMedida : posto.getHsPostoMedidaArray() ) - { - for( HsRiscoMedida relRiscoMedida : risco.getHsRiscoMedidaArray() ) - { - if( relRiscoMedida.getToHsMedida().equals( relPostoMedida.getToHsMedida() ) ) - { - medidas.add( relPostoMedida.getToHsMedida() ); - } - } + relatorio = new HsRelatorio(); + relatorio.setData( new Date() ); } - modelMedidas.setValues( medidas ); + panelRelatorio.setRelatorio( relatorio ); } } - private void fillMedida( HsMedida medida ) - { - textMedida.setText( "" ); - textRequisitosLegais.setText( "" ); - if( medida != null ) - { - textMedida.setText( medida.getDescription() ); - textRequisitosLegais.setText( medida.getRequesitosLegais() ); - } - } - - private void loadEmpresas() - { - comboEmpresas.removeAllItems(); - for( Empresas empresa : new MedicinaDAO().getAllEmpresas() ) - { - comboEmpresas.addItem( empresa ); - } - } - - private void loadValoresQualitativos() - { - comboValorQualitativo.removeAllItems(); - for( HsRelatorioRiscoValorQualitativo valor : provider.getAllValoresQualitativos() ) - { - comboValorQualitativo.addItem( valor ); - } - } - - private void loadEstabelecimentos( Empresas empresa ) - { - comboEstabelecimentos.removeAllItems(); - for( Estabelecimentos estabelecimento : empresa.getEstabelecimentosArray() ) - { - comboEstabelecimentos.addItem( estabelecimento ); - } - } - - - public static void main( String[] args ) - { - RelatorioHigieneSegurancaWindow window = new RelatorioHigieneSegurancaWindow(); - window.setVisible( true ); - window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); - } - @Override public void open() { @@ -744,6 +203,13 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable @Override public void refresh() { + + } + + public static void main( String[] args ) + { + RelatorioHigieneSegurancaWindow window = new RelatorioHigieneSegurancaWindow(); + window.setVisible( true ); + window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } - } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacoesPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacoesPanel.java new file mode 100644 index 00000000..a95ff703 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacoesPanel.java @@ -0,0 +1,10 @@ +package siprp.higiene.relatorio; + +import javax.swing.JPanel; + +public class RelatorioLegislacoesPanel extends JPanel +{ + + private static final long serialVersionUID = 1L; + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioWindow.java deleted file mode 100644 index 68e8071d..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioWindow.java +++ /dev/null @@ -1,717 +0,0 @@ -package siprp.higiene.relatorio; - -import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; -import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; -import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.List; -import java.util.Vector; - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import siprp.database.cayenne.objects.Empresas; -import siprp.database.cayenne.objects.Estabelecimentos; -import siprp.database.cayenne.objects.HsArea; -import siprp.database.cayenne.objects.HsMedida; -import siprp.database.cayenne.objects.HsPosto; -import siprp.database.cayenne.objects.HsPostoEstabelecimento; -import siprp.database.cayenne.objects.HsPostoMedida; -import siprp.database.cayenne.objects.HsPostoRisco; -import siprp.database.cayenne.objects.HsRelatorio; -import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo; -import siprp.database.cayenne.objects.HsRisco; -import siprp.database.cayenne.objects.HsRiscoMedida; -import siprp.database.cayenne.objects.MarcacoesEstabelecimento; -import siprp.database.cayenne.providers.MedicinaDAO; -import siprp.database.cayenne.providers.PlanoActuacaoDAO; - -import com.evolute.utils.tables.VectorTableModel; -import com.evolute.utils.ui.calendar.JCalendarPanel; - -public class RelatorioWindow extends JFrame -{ - private static final long serialVersionUID = 1L; - - public static final String TITLE = "Relat" + oacute + "rios de Higiene e Seguran" + ccedil + "a no Trabalho"; - - public static final Dimension SIZE = new Dimension( 800, 600 ); - - private final JComboBox comboEmpresas = new JComboBox(); - - private final JComboBox comboEstabelecimentos = new JComboBox(); - - private final VectorTableModel modelVisitas = new VectorTableModel( new String[]{ "Data" } ); - - private final JTable tableVisitas = new JTable( modelVisitas ); - - private final JScrollPane scrollVisitas = new JScrollPane( tableVisitas ); - - private final JButton buttonCriarRelatorio = new JButton("Criar Relat"+oacute+"rio"); - - private final JPanel panelRelatorio = new JPanel(); - - private final JCalendarPanel dateRelatorio = new JCalendarPanel( this ); - - private final JComboBox comboArea = new JComboBox(); - - private final JComboBox comboPosto = new JComboBox(); - - private final JPanel panelRiscos = new JPanel(); - - private final VectorTableModel modelRiscos = new VectorTableModel( new String[]{ "Riscos" } ); - - private final JTable tableRiscos = new JTable( modelRiscos ); - - private final JScrollPane scrollRiscos = new JScrollPane( tableRiscos ); - - private final JPanel panelRiscoValores = new JPanel(); - - 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 JComboBox comboValorQualitativo = new JComboBox(); - - private final JCheckBox checkPlanoActuacao = new JCheckBox("Plano de actua" + ccedil + atilde + "o" ); - - private final JPanel panelMedidas = new JPanel(); - - private final VectorTableModel modelMedidas = new VectorTableModel( new String[]{ "Medidas" } ); - - private final JTable tableMedidas = new JTable( modelMedidas ); - - private final JScrollPane scrollMedidas = new JScrollPane( tableMedidas ); - - private final JTextArea textMedida = new JTextArea(); - - private final JTextArea textRequisitosLegais = new JTextArea(); - - private final JButton buttonMedidaAdd = new JButton("Adicionar"); - - private final JButton buttonMedidaRemove = new JButton("Remover"); - - private final JButton buttonSubmeterRelatorio = new JButton( "Submeter Plano de Actua" + ccedil + atilde + "o" ); - - private final ItemListener listenerComboEmpresas = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedEmpresa(); - } - }; - - private final ItemListener listenerComboEstabelecimentos = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedEstabelecimento(); - } - }; - - private final ItemListener listenerComboArea = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedArea(); - } - }; - - private final ItemListener listenerComboPosto = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedPosto(); - } - }; - - private final ItemListener listenerComboValorQualitativo = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedValorQualitativo(); - } - }; - - private final PlanoActuacaoDAO provider = new PlanoActuacaoDAO(); - - public RelatorioWindow() - { - startupComponents(); - startupLayout(); - placeComponents(); - setupListeners(); - setTitle( TITLE ); - setSize( SIZE ); - loadEmpresas(); - loadValoresQualitativos(); - } - - private void startupComponents() - { - scrollMedidas.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollMedidas.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - scrollMedidas.setPreferredSize( new Dimension( 150, 0 ) ); - scrollRiscos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollRiscos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - scrollRiscos.setPreferredSize( new Dimension( 300, 0 ) ); - scrollVisitas.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scrollVisitas.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - scrollVisitas.setPreferredSize( new Dimension( 200, 0 ) ); - panelRelatorio.setBorder( BorderFactory.createTitledBorder( "Relat" + oacute + "rio" ) ); - panelRiscoValores.setBorder( BorderFactory.createTitledBorder( "Valores" ) ); - panelRiscos.setBorder( BorderFactory.createEtchedBorder() ); - panelMedidas.setBorder( BorderFactory.createEtchedBorder() ); - dateRelatorio.setPreferredSize( new Dimension( 150, 0 ) ); - textSeveridade.setPreferredSize( new Dimension( 30, 0 ) ); - textProbabilidade.setPreferredSize( new Dimension( 30, 0 ) ); - tableVisitas.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - tableRiscos.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - tableMedidas.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - ButtonGroup bg = new ButtonGroup(); - bg.add( radioValorQualitativo ); - bg.add( radioValorQuantitativo ); - } - - private void disableAndClearRelatorio( ) - { - dateRelatorio.setEnabled( false ); - dateRelatorio.clear(); - comboArea.setEnabled( false ); - comboPosto.setEnabled( false ); - buttonSubmeterRelatorio.setEnabled( false ); - disableAndClearRisco(); - disableAndClearMedida(); - } - - private void disableAndClearRisco() - { - modelRiscos.clearAll(); - radioValorQualitativo.setEnabled( false ); - radioValorQualitativo.setSelected( false ); - radioValorQuantitativo.setEnabled( false ); - radioValorQuantitativo.setSelected( false ); - textSeveridade.setEnabled( false ); - textSeveridade.setText( "" ); - textProbabilidade.setEnabled( false ); - textProbabilidade.setText( "" ); - comboValorQualitativo.setEnabled( false ); - checkPlanoActuacao.setEnabled( false ); - } - - private void disableAndClearMedida() - { - modelMedidas.clearAll(); - textMedida.setEnabled( false ); - textMedida.setText( "" ); - textRequisitosLegais.setEnabled( false ); - textRequisitosLegais.setText( "" ); - buttonMedidaAdd.setEnabled( false ); - buttonMedidaRemove.setEnabled( false ); - } - - private void startupLayout() - { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.PREFERRED, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - getContentPane().setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - panelRelatorio.setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.PREFERRED, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - panelRiscos.setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.PREFERRED }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - panelRiscoValores.setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM } - ); - layout.setVGap( 5 ); - layout.setHGap( 5 ); - panelMedidas.setLayout( layout ); - - } - - private void placeComponents() - { - - panelRiscoValores.add( radioValorQuantitativo, new TableLayoutConstraints( 0, 0 ) ); - panelRiscoValores.add( new JLabel("Severidade"), new TableLayoutConstraints( 1, 0 ) ); - panelRiscoValores.add( textSeveridade, new TableLayoutConstraints( 2, 0 ) ); - panelRiscoValores.add( new JLabel("Probabilidade"), new TableLayoutConstraints( 3, 0 ) ); - panelRiscoValores.add( textProbabilidade, new TableLayoutConstraints( 4, 0 ) ); - panelRiscoValores.add( radioValorQualitativo, new TableLayoutConstraints( 0, 1 ) ); - panelRiscoValores.add( comboValorQualitativo, new TableLayoutConstraints( 1, 1, 4, 1 ) ); - - panelRiscos.add( panelRiscoValores, new TableLayoutConstraints( 1, 0 ) ); - panelRiscos.add( checkPlanoActuacao, new TableLayoutConstraints( 1, 1 ) ); - panelRiscos.add( scrollRiscos, new TableLayoutConstraints( 0, 0, 0, 2 ) ); - - panelMedidas.add( scrollMedidas, new TableLayoutConstraints( 0, 0, 2, 3 ) ); - panelMedidas.add( buttonMedidaAdd, new TableLayoutConstraints( 0, 4 ) ); - panelMedidas.add( buttonMedidaRemove, new TableLayoutConstraints( 1, 4 ) ); - panelMedidas.add( new JLabel("Medidas"), new TableLayoutConstraints( 3, 0 ) ); - panelMedidas.add( textMedida, new TableLayoutConstraints( 3, 1 ) ); - panelMedidas.add( new JLabel("Requisitos Legais"), new TableLayoutConstraints( 3, 2 ) ); - panelMedidas.add( textRequisitosLegais, new TableLayoutConstraints( 3, 3 ) ); - - panelRelatorio.add( new JLabel("Data") , new TableLayoutConstraints( 0, 0 ) ); - panelRelatorio.add( dateRelatorio , new TableLayoutConstraints( 1, 0 ) ); - panelRelatorio.add( new JLabel("Areas") , new TableLayoutConstraints( 0, 1 ) ); - panelRelatorio.add( comboArea, new TableLayoutConstraints( 1, 1, 2, 1 ) ); - panelRelatorio.add( new JLabel("Postos de Trabalho") , new TableLayoutConstraints( 0, 2 ) ); - panelRelatorio.add( comboPosto, new TableLayoutConstraints( 1, 2, 2, 2 ) ); - panelRelatorio.add( buttonSubmeterRelatorio, new TableLayoutConstraints( 3, 0, 3, 2 ) ); - panelRelatorio.add( panelRiscos , new TableLayoutConstraints( 0, 3, 3, 3 ) ); - panelRelatorio.add( panelMedidas , new TableLayoutConstraints( 0, 4, 3, 4 ) ); - - getContentPane().add( new JLabel("Empresa"), new TableLayoutConstraints( 0, 0, 1, 0 ) ); - getContentPane().add( comboEmpresas, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - getContentPane().add( new JLabel("Estabelecimento"), new TableLayoutConstraints( 0, 2, 1, 2 ) ); - getContentPane().add( comboEstabelecimentos, new TableLayoutConstraints( 0, 3, 1, 3 ) ); - getContentPane().add( scrollVisitas, new TableLayoutConstraints( 0, 4 ) ); - getContentPane().add( buttonCriarRelatorio, new TableLayoutConstraints( 0, 5 ) ); - getContentPane().add( panelRelatorio, new TableLayoutConstraints( 1, 4, 1, 5 ) ); - } - - private void setupListeners() - { - comboEmpresas.addItemListener( listenerComboEmpresas ); - comboEstabelecimentos.addItemListener( listenerComboEstabelecimentos ); - comboArea.addItemListener( listenerComboArea ); - comboPosto.addItemListener( listenerComboPosto ); - comboValorQualitativo.addItemListener( listenerComboValorQualitativo ); - tableVisitas.getSelectionModel().addListSelectionListener( new ListSelectionListener() - { - @Override - public void valueChanged( ListSelectionEvent e ) - { - if( e.getValueIsAdjusting() && tableVisitas.getSelectedRowCount() > 0 ) - { - selectedVisita(); - } - } - } ); - tableRiscos.getSelectionModel().addListSelectionListener( new ListSelectionListener() - { - @Override - public void valueChanged( ListSelectionEvent e ) - { - if( e.getValueIsAdjusting() ) - { - selectedRisco(); - } - } - } ); - tableMedidas.getSelectionModel().addListSelectionListener( new ListSelectionListener() - { - @Override - public void valueChanged( ListSelectionEvent e ) - { - if( e.getValueIsAdjusting() ) - { - selectedMedida(); - } - } - } ); - buttonCriarRelatorio.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - criarRelatorio(); - } - } ); - radioValorQuantitativo.addItemListener( new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedRadioQuantitativo( ); - } - } ); - radioValorQualitativo.addItemListener( new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedRadioQualitativo( ); - } - } ); - checkPlanoActuacao.addItemListener( new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - selectedPlanoActuacao( ); - } - } ); - } - - private void criarRelatorio() - { - MarcacoesEstabelecimento visita = getSelectedVisita(); - HsRelatorio relatorio = provider.criarRelatorioForVisita( visita ); - if( relatorio != null ) - { - fillRelatorio( relatorio ); - } - } - - private HsRisco getSelectedRisco() - { - int selected = tableRiscos.getSelectedRow(); - return selected > -1 ? modelRiscos.getRowAt( selected ) : null; - } - - private HsPosto getSelectedPosto() - { - return (HsPosto) comboPosto.getSelectedItem(); - } - - private void selectedPlanoActuacao() - { - HsRisco risco = getSelectedRisco(); - HsPosto posto = getSelectedPosto(); - if( risco != null && posto != null ) - { - HsPostoRisco valores = getValores( risco, posto ); - if( valores == null ) - { - valores = provider.createValoresFor( risco, posto ); - } - valores.setIsPlanoActuacao( checkPlanoActuacao.isSelected() ? "y" : "n" ); - provider.commit(); - } - } - - private void selectedEmpresa() - { - disableAndClearRelatorio( ); - buttonCriarRelatorio.setEnabled( false ); - tableVisitas.setEnabled( false ); - modelVisitas.clearAll(); - Empresas empresa = (Empresas) comboEmpresas.getSelectedItem(); - loadEstabelecimentos( empresa ); - if( empresa == null ) - { - comboEstabelecimentos.setEnabled( false ); - } - } - - private void selectedEstabelecimento() - { - disableAndClearRelatorio( ); - modelVisitas.clearAll(); - buttonCriarRelatorio.setEnabled( false ); - Estabelecimentos estabelecimento = (Estabelecimentos) comboEstabelecimentos.getSelectedItem(); - if( estabelecimento != null ) - { - List marcacoes = estabelecimento.getMarcacoesEstabelecimentoArray(); - Vector filteredMarcacoes = new Vector(); - for( MarcacoesEstabelecimento marcacao : marcacoes ) - { - if( "y".equals( marcacao.getRealizada() ) ) - { - filteredMarcacoes.add( marcacao ); - } - } - modelVisitas.setValues( filteredMarcacoes ); - tableVisitas.setEnabled( true ); - } - } - - private void selectedArea() - { - disableAndClearRisco(); - disableAndClearMedida(); - HsArea area = (HsArea) comboArea.getSelectedItem(); - fillPostos( (Estabelecimentos) comboEstabelecimentos.getSelectedItem(), area ); - comboPosto.setEnabled( area != null ); - } - - private void selectedPosto() - { - modelRiscos.clearAll(); - HsPosto posto = (HsPosto) comboPosto.getSelectedItem(); - if( posto != null ) - { - Vector riscos = new Vector(); - for( HsPostoMedida rel : posto.getHsPostoMedidaArray() ) - { - for( HsRiscoMedida medidaRelRisco : rel.getToHsMedida().getHsRiscoMedidaArray() ) - { - riscos.add( medidaRelRisco.getToHsRisco() ); - } - } - modelRiscos.setValues( riscos ); - } - } - - private void selectedRadioQuantitativo() - { - textProbabilidade.setEnabled( true ) ; - textSeveridade.setEnabled( true ); - comboValorQualitativo.setEnabled( false ); - } - - private void selectedRadioQualitativo() - { - textProbabilidade.setEnabled( false ); - textSeveridade.setEnabled( false ); - comboValorQualitativo.setEnabled( true ); - } - - private void selectedValorQualitativo() - { - - } - - private void selectedRisco() - { - disableAndClearMedida(); - int selected = tableRiscos.getSelectedRow(); - HsRisco risco = selected > -1 ? modelRiscos.getRowAt( selected ) : null; - checkPlanoActuacao.setEnabled( risco != null ); - radioValorQualitativo.setEnabled( risco != null ); - radioValorQuantitativo.setEnabled( risco != null ); - fillRisco( risco, (HsPosto) comboPosto.getSelectedItem() ); - } - - private void selectedMedida() - { - int selected = tableMedidas.getSelectedRow(); - HsMedida medida = selected > -1 ? modelMedidas.getRowAt( selected ) : null; - textMedida.setEnabled( medida != null ); - textRequisitosLegais.setEnabled( medida != null ); - fillMedida( medida ); - } - - private MarcacoesEstabelecimento getSelectedVisita() - { - MarcacoesEstabelecimento result = null; - int row = tableVisitas.getSelectedRow(); - if( row > -1 ) - { - result = modelVisitas.getRowAt( row ); - } - return result; - } - - private void selectedVisita() - { - disableAndClearRelatorio( ); - MarcacoesEstabelecimento visita = getSelectedVisita(); - List relatorios = visita.getHsRelatorioArray(); - HsRelatorio relatorio = null; - for( HsRelatorio current : relatorios ) - { - if( current.getDeletedDate() == null) - { - relatorio = current; - break; - } - } - if( relatorio == null ) - { - buttonCriarRelatorio.setEnabled( true ); - } - else - { - fillRelatorio( relatorio ); - buttonCriarRelatorio.setEnabled( false ); - } - } - - private void fillRelatorio( HsRelatorio relatorio ) - { - boolean submetido = relatorio.getIsSubmetido() != null; - dateRelatorio.setEnabled( !submetido ); - dateRelatorio.setDate( relatorio.getData() ); - buttonSubmeterRelatorio.setEnabled( !submetido ); - comboArea.setEnabled( true ); - fillAreas( relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos() ); - } - - private void fillAreas( Estabelecimentos estabelecimento ) - { - comboArea.removeAllItems(); - if( estabelecimento != null ) - { - for( HsArea area : new Vector( estabelecimento.getToEmpresas().getHsAreaArray() ) ) - { - comboArea.addItem( area ); - } - } - } - - private void fillPostos( Estabelecimentos estabelecimento, HsArea area ) - { - comboPosto.removeAllItems(); - if( estabelecimento != null && area != null ) - { - for( HsPostoEstabelecimento rel : estabelecimento.getHsPostoEstabelecimentoArray() ) - { - if( area.getHsPostoArray().contains( rel.getToHsPosto() ) ) - { - comboPosto.addItem( rel.getToHsPosto() ); - } - } - } - } - - private HsPostoRisco getValores( HsRisco risco, HsPosto posto ) - { - HsPostoRisco result = null; - if( risco != null && posto != null ) - { - for( HsPostoRisco valores : risco.getHsPostoRiscoArray() ) - { - if( valores.getToHsPosto().equals( posto ) ) - { - result = valores; - break; - } - } - } - return result; - } - - private void fillRisco( HsRisco risco, HsPosto posto ) - { - modelMedidas.clearAll(); - textProbabilidade.setText( "" ); - textSeveridade.setText( "" ); - checkPlanoActuacao.setSelected( false ); - radioValorQuantitativo.setSelected( true ); - if( risco != null && posto != null ) - { - HsPostoRisco valores = getValores( risco, posto ); - if( valores != null ) - { - if( valores.getToHsRelatorioRiscoValorQualitativo() != null ) - { - radioValorQualitativo.setSelected( true ); - } - else - { - radioValorQuantitativo.setSelected( true ); - textProbabilidade.setText( valores.getProbabilidade() != null ? valores.getProbabilidade() + "" : "" ); - textSeveridade.setText( valores.getSeveridade() != null ? valores.getSeveridade() + "" : "" ); - checkPlanoActuacao.setSelected( "y".equals( valores.getIsPlanoActuacao() ) ); - } - } - Vector medidas = new Vector(); - for( HsPostoMedida relPostoMedida : posto.getHsPostoMedidaArray() ) - { - for( HsRiscoMedida relRiscoMedida : risco.getHsRiscoMedidaArray() ) - { - if( relRiscoMedida.getToHsMedida().equals( relPostoMedida.getToHsMedida() ) ) - { - medidas.add( relPostoMedida.getToHsMedida() ); - } - } - } - modelMedidas.setValues( medidas ); - } - } - - private void fillMedida( HsMedida medida ) - { - textMedida.setText( "" ); - textRequisitosLegais.setText( "" ); - if( medida != null ) - { - textMedida.setText( medida.getDescription() ); - textRequisitosLegais.setText( medida.getRequesitosLegais() ); - } - } - - private void loadEmpresas() - { - comboEmpresas.removeAllItems(); - for( Empresas empresa : new MedicinaDAO().getAllEmpresas() ) - { - comboEmpresas.addItem( empresa ); - } - } - - private void loadValoresQualitativos() - { - comboValorQualitativo.removeAllItems(); - for( HsRelatorioRiscoValorQualitativo valor : provider.getAllValoresQualitativos() ) - { - comboValorQualitativo.addItem( valor ); - } - } - - private void loadEstabelecimentos( Empresas empresa ) - { - comboEstabelecimentos.removeAllItems(); - for( Estabelecimentos estabelecimento : empresa.getEstabelecimentosArray() ) - { - comboEstabelecimentos.addItem( estabelecimento ); - } - } - - - public static void main( String[] args ) - { - RelatorioWindow window = new RelatorioWindow(); - window.setVisible( true ); - window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java index db7fbae1..0af87abc 100644 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java +++ b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java @@ -37,7 +37,8 @@ public class UpdateList new siprp.update.updates.V9_1_To_V9_2(), new siprp.update.updates.V9_2_To_V9_3(), new siprp.update.updates.V9_3_To_V9_4(), new siprp.update.updates.V9_4_To_V9_5(), new siprp.update.updates.V9_5_To_V9_6(), new siprp.update.updates.V9_6_To_V9_7(), - new siprp.update.updates.V9_7_To_V9_8(), new siprp.update.updates.V9_8_To_V9_9() }; + new siprp.update.updates.V9_7_To_V9_8(), new siprp.update.updates.V9_8_To_V9_9(), + new siprp.update.updates.V9_9_To_V10_0() }; protected static Executer EXECUTER; protected static double version = -1; diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V9_9_To_V10_0.java b/trunk/SIPRPSoft/src/siprp/update/updates/V9_9_To_V10_0.java new file mode 100644 index 00000000..573f13c0 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/update/updates/V9_9_To_V10_0.java @@ -0,0 +1,73 @@ +package siprp.update.updates; + +import com.evolute.utils.Singleton; +import com.evolute.utils.db.DBManager; +import com.evolute.utils.db.Executer; + +/** + * + * @author fpalma + */ +public class V9_9_To_V10_0 + implements siprp.update.Update +{ + + public V9_9_To_V10_0() + { + } + + public String []listChanges() + { + return new String[]{ + "extensao da definicao de 'relatorio de higiene e seguranca'" + }; + } + + public double getStartVersion() + { + return 9.9; + } + + public double getEndVersion() + { + return 10.0; + } + + public void doUpdate() + throws Exception + { + DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); + Executer executer = dbm.getSharedExecuter(); + com.evolute.utils.sql.Update update = + new com.evolute.utils.sql.Update( + "create table hs_relatorio_legislacao( " + + " hs_relatorio_id int4 REFERENCES hs_relatorio(id), " + + " hs_legislacao_id int4 REFERENCES hs_legislacao(id), " + + " CONSTRAINT hs_relatorio_legislacao_pkey PRIMARY KEY (hs_relatorio_id,hs_legislacao_id) " + + "); " + + "create table hs_relatorio_normalizacao( " + + " hs_relatorio_id int4 REFERENCES hs_relatorio(id), " + + " hs_normalizacao_id int4 REFERENCES hs_normalizacao(id), " + + " CONSTRAINT hs_relatorio_normalizacao_pkey PRIMARY KEY (hs_relatorio_id,hs_normalizacao_id) " + + "); " + + "create table hs_relatorio_equipamento_medicao( " + + " hs_relatorio_id int4 REFERENCES hs_relatorio(id), " + + " hs_equipamento_medicao_id int4 REFERENCES hs_normalizacao(id), " + + " CONSTRAINT hs_relatorio_equipamento_medicao_pkey PRIMARY KEY (hs_relatorio_id,hs_equipamento_medicao_id) " + + "); " + + "alter table hs_relatorio add column avaliacao_inicial boolean; " + + "alter table hs_relatorio add column acompanhante1 varchar(256); " + + "alter table hs_relatorio add column funcao_acompanhante1 varchar(128); " + + "alter table hs_relatorio add column acompanhante2 varchar(256); " + + "alter table hs_relatorio add column funcao_acompanhante2 varchar(128); " + + "alter table hs_relatorio add column acompanhante3 varchar(256); " + + "alter table hs_relatorio add column funcao_acompanhante3 varchar(128);" + ); + executer.executeQuery( update ); + } + + public String toString() + { + return "v" + getStartVersion() + " para v" + getEndVersion(); + } +} diff --git a/trunk/common/src/SIPRPMap.map.xml b/trunk/common/src/SIPRPMap.map.xml index d88e903f..10d282d9 100644 --- a/trunk/common/src/SIPRPMap.map.xml +++ b/trunk/common/src/SIPRPMap.map.xml @@ -298,8 +298,14 @@ + + + + + + @@ -319,6 +325,14 @@ 1 + + + + + + + + @@ -331,6 +345,10 @@ 1 + + + + @@ -929,8 +947,14 @@ + + + + + + @@ -938,11 +962,17 @@ + + + + + + @@ -1352,9 +1382,21 @@ + + + + + + + + + + + + @@ -1364,12 +1406,21 @@ + + + + + + + + + @@ -1406,6 +1457,9 @@ + + + @@ -1766,11 +1820,17 @@ + + + + + + diff --git a/trunk/common/src/leaf/ui/LeafIconButton.java b/trunk/common/src/leaf/ui/LeafIconButton.java new file mode 100644 index 00000000..8dc8753c --- /dev/null +++ b/trunk/common/src/leaf/ui/LeafIconButton.java @@ -0,0 +1,34 @@ +package leaf.ui; + +import java.awt.Insets; + +import com.evolute.utils.images.ImageException; +import com.evolute.utils.images.ImageIconLoader; + +public class LeafIconButton extends LeafButton +{ + private static final long serialVersionUID = 1L; + + private LeafIconButton( String imagePath ) throws ImageException + { + super(ImageIconLoader.loadImageIcon( imagePath )); + } + + public static LeafIconButton createButton( String imagePath ) + { + LeafIconButton result = null; + if( imagePath != null ) + { + try + { + result = new LeafIconButton(imagePath); + result.setMargin( new Insets(0,0,0,0) ); + } catch( ImageException e ) + { + e.printStackTrace(); + } + } + return result; + } + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioEquipamentoMedicao.java b/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioEquipamentoMedicao.java new file mode 100644 index 00000000..89ba56d4 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioEquipamentoMedicao.java @@ -0,0 +1,7 @@ +package siprp.database.cayenne.objects; + +import siprp.database.cayenne.objects.auto._HsRelatorioEquipamentoMedicao; + +public class HsRelatorioEquipamentoMedicao extends _HsRelatorioEquipamentoMedicao { + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioLegislacao.java b/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioLegislacao.java new file mode 100644 index 00000000..c235a6a2 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioLegislacao.java @@ -0,0 +1,7 @@ +package siprp.database.cayenne.objects; + +import siprp.database.cayenne.objects.auto._HsRelatorioLegislacao; + +public class HsRelatorioLegislacao extends _HsRelatorioLegislacao { + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioNormalizacao.java b/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioNormalizacao.java new file mode 100644 index 00000000..671f89c3 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/HsRelatorioNormalizacao.java @@ -0,0 +1,7 @@ +package siprp.database.cayenne.objects; + +import siprp.database.cayenne.objects.auto._HsRelatorioNormalizacao; + +public class HsRelatorioNormalizacao extends _HsRelatorioNormalizacao { + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorio.java b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorio.java index 3d6b4f3e..c08383fe 100644 --- a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorio.java +++ b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorio.java @@ -4,6 +4,9 @@ import java.util.Date; import java.util.List; import siprp.database.cayenne.objects.BaseObject; +import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedicao; +import siprp.database.cayenne.objects.HsRelatorioLegislacao; +import siprp.database.cayenne.objects.HsRelatorioNormalizacao; import siprp.database.cayenne.objects.HsRelatorioRisco; import siprp.database.cayenne.objects.MarcacoesEstabelecimento; @@ -15,15 +18,45 @@ import siprp.database.cayenne.objects.MarcacoesEstabelecimento; */ public abstract class _HsRelatorio extends BaseObject { + public static final String ACOMPANHANTE2_PROPERTY = "acompanhante2"; + public static final String ACOMPANHANTE3_PROPERTY = "acompanhante3"; + public static final String AVALIACAO_INICIAL_PROPERTY = "avaliacaoInicial"; public static final String DATA_PROPERTY = "data"; public static final String DELETED_DATE_PROPERTY = "deletedDate"; + public static final String FUNCAO_ACOMPANHANTE1_PROPERTY = "funcaoAcompanhante1"; + public static final String FUNCAO_ACOMPANHANTE2_PROPERTY = "funcaoAcompanhante2"; + public static final String FUNCAO_ACOMPANHANTE3_PROPERTY = "funcaoAcompanhante3"; public static final String ID_PROPERTY = "id"; public static final String IS_SUBMETIDO_PROPERTY = "isSubmetido"; + public static final String HS_RELATORIO_EQUIPAMENTO_MEDICAO_ARRAY_PROPERTY = "hsRelatorioEquipamentoMedicaoArray"; + public static final String HS_RELATORIO_LEGISLACAO_ARRAY_PROPERTY = "hsRelatorioLegislacaoArray"; + public static final String HS_RELATORIO_NORMALIZACAO_ARRAY_PROPERTY = "hsRelatorioNormalizacaoArray"; public static final String HS_RELATORIO_RISCO_ARRAY_PROPERTY = "hsRelatorioRiscoArray"; public static final String TO_HS_MARCACOES_ESTABELECIMENTO_PROPERTY = "toHsMarcacoesEstabelecimento"; public static final String ID_PK_COLUMN = "id"; + public void setAcompanhante2(String acompanhante2) { + writeProperty("acompanhante2", acompanhante2); + } + public String getAcompanhante2() { + return (String)readProperty("acompanhante2"); + } + + public void setAcompanhante3(String acompanhante3) { + writeProperty("acompanhante3", acompanhante3); + } + public String getAcompanhante3() { + return (String)readProperty("acompanhante3"); + } + + public void setAvaliacaoInicial(Boolean avaliacaoInicial) { + writeProperty("avaliacaoInicial", avaliacaoInicial); + } + public Boolean getAvaliacaoInicial() { + return (Boolean)readProperty("avaliacaoInicial"); + } + public void setData(Date data) { writeProperty("data", data); } @@ -38,6 +71,27 @@ public abstract class _HsRelatorio extends BaseObject { return (Date)readProperty("deletedDate"); } + public void setFuncaoAcompanhante1(String funcaoAcompanhante1) { + writeProperty("funcaoAcompanhante1", funcaoAcompanhante1); + } + public String getFuncaoAcompanhante1() { + return (String)readProperty("funcaoAcompanhante1"); + } + + public void setFuncaoAcompanhante2(String funcaoAcompanhante2) { + writeProperty("funcaoAcompanhante2", funcaoAcompanhante2); + } + public String getFuncaoAcompanhante2() { + return (String)readProperty("funcaoAcompanhante2"); + } + + public void setFuncaoAcompanhante3(String funcaoAcompanhante3) { + writeProperty("funcaoAcompanhante3", funcaoAcompanhante3); + } + public String getFuncaoAcompanhante3() { + return (String)readProperty("funcaoAcompanhante3"); + } + public void setId(Integer id) { writeProperty("id", id); } @@ -52,6 +106,42 @@ public abstract class _HsRelatorio extends BaseObject { return (Date)readProperty("isSubmetido"); } + public void addToHsRelatorioEquipamentoMedicaoArray(HsRelatorioEquipamentoMedicao obj) { + addToManyTarget("hsRelatorioEquipamentoMedicaoArray", obj, true); + } + public void removeFromHsRelatorioEquipamentoMedicaoArray(HsRelatorioEquipamentoMedicao obj) { + removeToManyTarget("hsRelatorioEquipamentoMedicaoArray", obj, true); + } + @SuppressWarnings("unchecked") + public List getHsRelatorioEquipamentoMedicaoArray() { + return (List)readProperty("hsRelatorioEquipamentoMedicaoArray"); + } + + + public void addToHsRelatorioLegislacaoArray(HsRelatorioLegislacao obj) { + addToManyTarget("hsRelatorioLegislacaoArray", obj, true); + } + public void removeFromHsRelatorioLegislacaoArray(HsRelatorioLegislacao obj) { + removeToManyTarget("hsRelatorioLegislacaoArray", obj, true); + } + @SuppressWarnings("unchecked") + public List getHsRelatorioLegislacaoArray() { + return (List)readProperty("hsRelatorioLegislacaoArray"); + } + + + public void addToHsRelatorioNormalizacaoArray(HsRelatorioNormalizacao obj) { + addToManyTarget("hsRelatorioNormalizacaoArray", obj, true); + } + public void removeFromHsRelatorioNormalizacaoArray(HsRelatorioNormalizacao obj) { + removeToManyTarget("hsRelatorioNormalizacaoArray", obj, true); + } + @SuppressWarnings("unchecked") + public List getHsRelatorioNormalizacaoArray() { + return (List)readProperty("hsRelatorioNormalizacaoArray"); + } + + public void addToHsRelatorioRiscoArray(HsRelatorioRisco obj) { addToManyTarget("hsRelatorioRiscoArray", obj, true); } diff --git a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioEquipamentoMedicao.java b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioEquipamentoMedicao.java new file mode 100644 index 00000000..90eef2a9 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioEquipamentoMedicao.java @@ -0,0 +1,29 @@ +package siprp.database.cayenne.objects.auto; + +import org.apache.cayenne.CayenneDataObject; + +import siprp.database.cayenne.objects.HsRelatorio; + +/** + * Class _HsRelatorioEquipamentoMedicao was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _HsRelatorioEquipamentoMedicao extends CayenneDataObject { + + public static final String TO_HS_RELATORIO_PROPERTY = "toHsRelatorio"; + + public static final String HS_EQUIPAMENTO_MEDICAO_ID_PK_COLUMN = "hs_equipamento_medicao_id"; + public static final String HS_RELATORIO_ID_PK_COLUMN = "hs_relatorio_id"; + + public void setToHsRelatorio(HsRelatorio toHsRelatorio) { + setToOneTarget("toHsRelatorio", toHsRelatorio, true); + } + + public HsRelatorio getToHsRelatorio() { + return (HsRelatorio)readProperty("toHsRelatorio"); + } + + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioLegislacao.java b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioLegislacao.java new file mode 100644 index 00000000..004ed81c --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioLegislacao.java @@ -0,0 +1,29 @@ +package siprp.database.cayenne.objects.auto; + +import org.apache.cayenne.CayenneDataObject; + +import siprp.database.cayenne.objects.HsRelatorio; + +/** + * Class _HsRelatorioLegislacao was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _HsRelatorioLegislacao extends CayenneDataObject { + + public static final String TO_HS_RELATORIO_PROPERTY = "toHsRelatorio"; + + public static final String HS_LEGISLACAO_ID_PK_COLUMN = "hs_legislacao_id"; + public static final String HS_RELATORIO_ID_PK_COLUMN = "hs_relatorio_id"; + + public void setToHsRelatorio(HsRelatorio toHsRelatorio) { + setToOneTarget("toHsRelatorio", toHsRelatorio, true); + } + + public HsRelatorio getToHsRelatorio() { + return (HsRelatorio)readProperty("toHsRelatorio"); + } + + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioNormalizacao.java b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioNormalizacao.java new file mode 100644 index 00000000..7ae0732e --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRelatorioNormalizacao.java @@ -0,0 +1,29 @@ +package siprp.database.cayenne.objects.auto; + +import org.apache.cayenne.CayenneDataObject; + +import siprp.database.cayenne.objects.HsRelatorio; + +/** + * Class _HsRelatorioNormalizacao was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _HsRelatorioNormalizacao extends CayenneDataObject { + + public static final String TO_HS_RELATORIO_PROPERTY = "toHsRelatorio"; + + public static final String HS_NORMALIZACAO_ID_PK_COLUMN = "hs_normalizacao_id"; + public static final String HS_RELATORIO_ID_PK_COLUMN = "hs_relatorio_id"; + + public void setToHsRelatorio(HsRelatorio toHsRelatorio) { + setToOneTarget("toHsRelatorio", toHsRelatorio, true); + } + + public HsRelatorio getToHsRelatorio() { + return (HsRelatorio)readProperty("toHsRelatorio"); + } + + +} diff --git a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java index 914339f0..c4060c63 100644 --- a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java @@ -14,6 +14,7 @@ import siprp.database.cayenne.objects.HsRisco; import siprp.database.cayenne.objects.HsRiscoEmpresa; import siprp.database.cayenne.objects.HsRiscoMedida; import siprp.database.cayenne.objects.HsRiscoTema; +import siprp.database.cayenne.providers.MedicinaDAO; import siprp.database.cayenne.providers.PlanoActuacaoDAO; import siprp.higiene.gestao.postos.AreaNode; import siprp.higiene.gestao.postos.PostoNode; @@ -24,12 +25,13 @@ import siprp.higiene.gestao.riscos.NodeRiscoTema; public class HigieneSegurancaLogic { - private static final PlanoActuacaoDAO provider = new PlanoActuacaoDAO(); + private static final PlanoActuacaoDAO planoProvider = new PlanoActuacaoDAO(); + private static final MedicinaDAO medicinaProvider = new MedicinaDAO(); public static DefaultMutableTreeNode getRiscosTree() { DefaultMutableTreeNode result = new DefaultMutableTreeNode(); - List temas = provider.getAllRiscoTemas(); + List temas = planoProvider.getAllRiscoTemas(); if( temas != null ) { for( HsRiscoTema tema : temas ) @@ -121,4 +123,9 @@ public class HigieneSegurancaLogic } return result; } + + public static List getAllEmpresas() + { + return medicinaProvider.getAllEmpresas(); + } }