forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@805 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
933e9a2797
commit
5812d0b814
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package siprp.higiene.legislacao;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class GestaoDadosRelatorioWindow extends JFrame
|
||||
{
|
||||
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package siprp.higiene.relatorio;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class RelatorioLegislacoesPanel extends JPanel
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@ -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<MarcacoesEstabelecimento> modelVisitas = new VectorTableModel<MarcacoesEstabelecimento>( 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<HsRisco> modelRiscos = new VectorTableModel<HsRisco>( 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<HsMedida> modelMedidas = new VectorTableModel<HsMedida>( 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<MarcacoesEstabelecimento> marcacoes = estabelecimento.getMarcacoesEstabelecimentoArray();
|
||||
Vector<MarcacoesEstabelecimento> filteredMarcacoes = new Vector<MarcacoesEstabelecimento>();
|
||||
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<HsRisco> riscos = new Vector<HsRisco>();
|
||||
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<HsRelatorio> 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<HsArea>( 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<HsMedida> medidas = new Vector<HsMedida>();
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package siprp.database.cayenne.objects;
|
||||
|
||||
import siprp.database.cayenne.objects.auto._HsRelatorioEquipamentoMedicao;
|
||||
|
||||
public class HsRelatorioEquipamentoMedicao extends _HsRelatorioEquipamentoMedicao {
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package siprp.database.cayenne.objects;
|
||||
|
||||
import siprp.database.cayenne.objects.auto._HsRelatorioLegislacao;
|
||||
|
||||
public class HsRelatorioLegislacao extends _HsRelatorioLegislacao {
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package siprp.database.cayenne.objects;
|
||||
|
||||
import siprp.database.cayenne.objects.auto._HsRelatorioNormalizacao;
|
||||
|
||||
public class HsRelatorioNormalizacao extends _HsRelatorioNormalizacao {
|
||||
|
||||
}
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue