diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java index 700034db..1b70aa17 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -6,6 +6,7 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import static com.evolute.utils.strings.UnicodeLatin1Map.eacute; import static com.evolute.utils.strings.UnicodeLatin1Map.iacute; 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; @@ -36,6 +37,7 @@ import javax.swing.event.CaretListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import leaf.ui.LeafButton; import leaf.ui.LeafError; import leaf.ui.LeafIconButton; import siprp.database.cayenne.objects.HsEmailEstabelecimento; @@ -43,6 +45,7 @@ import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.MarcacoesEstabelecimento; import siprp.database.cayenne.objects.MarcacoesTecnicosHst; import siprp.higiene.gestao.equipamentos.AdicionarEquipamentosPanel; +import siprp.logic.HigieneSegurancaLogic; import siprp.medicina.processo.mail.MailDialog; import siprp.planoactuacao.print.PlanoActuacaoPDFCreator; @@ -57,6 +60,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png"; private static final String ICON_NAME_SUBMIT = "siprp/higiene/relatorio/submit.png"; private static final String ICON_NAME_PDF = "siprp/higiene/relatorio/adobe_reader.png"; + private static final String ICON_NAME_UNDO = "siprp/higiene/relatorio/revert.png"; private final JCalendarPanel dataRelatorio = new JCalendarPanel( null ); @@ -74,11 +78,12 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe private final JTextField fieldFuncao2 = new JTextField(); private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE ); - private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT ); - private final LeafIconButton buttonSubmit = LeafIconButton.createButton( "Submeter plano de actua" + ccedil + atilde + "o", ICON_NAME_SUBMIT ); + private final LeafIconButton buttonRevertText = LeafIconButton.createButton( ICON_NAME_REVERT ); + private final LeafIconButton buttonSubmit = LeafIconButton.createButton( "Submeter", ICON_NAME_SUBMIT ); private final LeafIconButton buttonPdfPlano = LeafIconButton.createButton( "Plano de actua" + ccedil + atilde + "o", ICON_NAME_PDF ); private final LeafIconButton buttonPdfRelatorio = LeafIconButton.createButton( "Relat" + oacute + "rio", ICON_NAME_PDF ); - + private final LeafButton buttonRevertPlano = LeafIconButton.createButton( "Recarregar", ICON_NAME_UNDO ); + private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel(); private final JTabbedPane tabs = new JTabbedPane(); @@ -113,10 +118,9 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe tabs.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano ); tabs.addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao ); tabs.addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao ); - tabs.setEnabledAt( 1, false ); - tabs.setEnabledAt( 2, false ); buttonSave.setToolTipText( "Guardar" ); - buttonRevert.setToolTipText( "Reverter" ); + buttonRevertText.setToolTipText( "Reverter" ); + buttonRevertPlano.setToolTipText( "Carregar dados do estabelecimento" ); } private void startupLayout() @@ -152,7 +156,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe panelAcompanhantes.add( fieldFuncao2, new TableLayoutConstraints( 3, 1 ) ); TableLayout layout = new TableLayout( new double[] { - TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM }, new double[] { TableLayout.MINIMUM } ); @@ -162,10 +166,11 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe panel.setLayout( layout ); panel.add( buttonSave, new TableLayoutConstraints( 0, 0 ) ); - panel.add( buttonRevert, new TableLayoutConstraints( 1, 0 ) ); + panel.add( buttonRevertText, new TableLayoutConstraints( 1, 0 ) ); panel.add( buttonPdfRelatorio, new TableLayoutConstraints( 3, 0 ) ); panel.add( buttonPdfPlano, new TableLayoutConstraints( 4, 0 ) ); - panel.add( buttonSubmit, new TableLayoutConstraints( 5, 0 ) ); + panel.add( buttonRevertPlano, new TableLayoutConstraints( 5, 0 ) ); + panel.add( buttonSubmit, new TableLayoutConstraints( 6, 0 ) ); add( panel, new TableLayoutConstraints( 0, 0, 7, 0 ) ); add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 1, 2, 1 ) ); @@ -199,7 +204,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe save(); } } ); - buttonRevert.addActionListener( new ActionListener() + buttonRevertText.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) @@ -229,6 +234,27 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe pdf(); } } ); + buttonRevertPlano.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + revert(true); + } + } ); + } + + protected void revert( boolean ask ) + { + if( relatorio != null ) + { + int ret = ask == false ? JOptionPane.YES_OPTION : JOptionPane.showConfirmDialog( this, "Todas as altera" + ccedil + otilde + "es ao plano de actua" + ccedil + atilde + "o ser" + atilde + "o perdidas\nTem a certeza?","Carregar dados do estabelecimento",JOptionPane.YES_NO_OPTION); + if( JOptionPane.YES_OPTION == ret ) + { + HigieneSegurancaLogic.reverterRelatorio(relatorio); + setRelatorio( relatorio, false ); + } + } } private boolean isValidEmail() @@ -423,7 +449,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText()); relatorio.save(); refresh(); - buttonRevert.setEnabled( false ); + buttonRevertText.setEnabled( false ); buttonSave.setEnabled( false ); } catch( Exception e ) { @@ -434,7 +460,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe private void revert() { refresh(); - buttonRevert.setEnabled( false ); + buttonRevertText.setEnabled( false ); buttonSave.setEnabled( false ); } @@ -483,18 +509,21 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe fieldFuncao2.setEnabled( enabled ); buttonSubmit.setEnabled( enabled ); buttonPdfPlano.setEnabled( enabled ); + buttonRevertPlano.setEnabled( enabled ); } public void setRelatorio( HsRelatorio relatorio,boolean create ) { this.relatorio = relatorio; buttonSave.setEnabled( false ); - buttonRevert.setEnabled( false ); + buttonRevertText.setEnabled( false ); panelEquipamentos.setRelatorio( relatorio ); panelPlano.setRelatorio( relatorio ); + panelLegislacao.setRelatorio( relatorio ); + panelNormalizacao.setRelatorio( relatorio ); if( create ) { - panelPlano.revert(false); + this.revert(false); } refresh(); setEnabled(); @@ -508,7 +537,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe if( ( (Component) source).isEnabled() ) { buttonSave.setEnabled( true ); - buttonRevert.setEnabled( true ); + buttonRevertText.setEnabled( true ); } } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java index 5964b3b3..f3562d0e 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java @@ -1,24 +1,16 @@ 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.otilde; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; import java.awt.CardLayout; import java.awt.Dimension; -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.JOptionPane; import javax.swing.JPanel; -import leaf.ui.LeafButton; -import leaf.ui.LeafIconButton; import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorioArea; import siprp.database.cayenne.objects.HsRelatorioPosto; @@ -31,8 +23,6 @@ public class PlanoActuacaoPanel extends JPanel private static final long serialVersionUID = 1L; - private static final String ICON_NAME_REVERT = "siprp/higiene/relatorio/revert.png"; - private static final String RISCO_PANEL = "RISCO_PANEL"; private static final String MEDIDA_PANEL = "MEDIDA_PANEL"; @@ -53,7 +43,7 @@ public class PlanoActuacaoPanel extends JPanel private final CardLayout cards = new CardLayout(); - private final LeafButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT ); + private HsRelatorio relatorio = null; @@ -106,14 +96,6 @@ public class PlanoActuacaoPanel extends JPanel } } } ); - buttonRevert.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - revert(true); - } - } ); valoresRisco.addPropertyChangeListener( GerirValoresRiscoPanel.VALUE_CHANGED, new PropertyChangeListener() { @Override @@ -133,25 +115,11 @@ public class PlanoActuacaoPanel extends JPanel } ); } - protected void revert( boolean ask ) - { - if( relatorio != null ) - { - int ret = ask == false ? JOptionPane.YES_OPTION : JOptionPane.showConfirmDialog( this, "Todas as altera" + ccedil + otilde + "es ao plano de actua" + ccedil + atilde + "o ser" + atilde + "o perdidas\nTem a certeza?","Carregar dados do estabelecimento",JOptionPane.YES_NO_OPTION); - if( JOptionPane.YES_OPTION == ret ) - { - HigieneSegurancaLogic.reverterRelatorio(relatorio); - setRelatorio( relatorio ); - } - } - } - private void startupComponents() { riscos.setBorder( BorderFactory.createTitledBorder( "Riscos" ) ); areas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) ); areas.setPreferredSize( new Dimension(250,0) ); - buttonRevert.setToolTipText( "Carregar dados do estabelecimento" ); } private void startupLayout() @@ -171,7 +139,6 @@ public class PlanoActuacaoPanel extends JPanel valoresPanel.add( valoresRisco, RISCO_PANEL ); valoresPanel.add( valoresMedida, MEDIDA_PANEL ); valoresPanel.add( emptyPanel, EMPTY_PANEL ); - add( buttonRevert, new TableLayoutConstraints( 0, 0 ) ); add( areas, new TableLayoutConstraints( 0, 1, 1, 1 ) ); add( riscos, new TableLayoutConstraints( 2, 1 ) ); add( valoresPanel, new TableLayoutConstraints( 3, 1 ) ); @@ -179,7 +146,7 @@ public class PlanoActuacaoPanel extends JPanel private void setEnabled() { - buttonRevert.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null ); + } public void setRelatorio( HsRelatorio relatorio ) diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java index 51a084a1..6c7ed60d 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java @@ -130,6 +130,7 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable } } } ); + } private void fillEstabelecimentos( Empresas empresa ) diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java index ed0dea95..d25790bb 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java @@ -1,10 +1,74 @@ package siprp.higiene.relatorio; +import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; +import info.clearthought.layout.TableLayout; +import info.clearthought.layout.TableLayoutConstraints; + +import java.util.Collections; +import java.util.List; +import java.util.Vector; + import javax.swing.JPanel; +import leaf.ui.SimpleTable; +import siprp.database.cayenne.objects.HsRelatorio; +import siprp.database.cayenne.objects.HsRelatorioLegislacao; + +import com.evolute.utils.tables.ColumnizedObjectArray; + public class RelatorioLegislacaoPanel extends JPanel { private static final long serialVersionUID = 1L; + + private HsRelatorio relatorio = null; + + private final SimpleTable table = new SimpleTable( "Categoria", "Legisla" + ccedil + atilde + "o" ); + + public RelatorioLegislacaoPanel() + { + startupComponents(); + setupLayout(); + placeComponents(); + } + + private void startupComponents() + { + table.getTable().fixColumnWidth(0,200); + } + + private void setupLayout() + { + TableLayout layout = new TableLayout( new double[]{ TableLayout.FILL }, new double[]{ TableLayout.FILL } ); + this.setLayout( layout ); + } + + private void placeComponents() + { + this.add( table, new TableLayoutConstraints( 0, 0 ) ); + } + + public void setRelatorio( HsRelatorio relatorio ) + { + this.relatorio = relatorio; + refresh(); + } + + private void refresh() + { + table.clear(); + if( relatorio != null ) + { + List legislacoes = relatorio.getHsRelatorioLegislacaoArray(); + Collections.sort( legislacoes ); + Vector rows = new Vector(); + for( HsRelatorioLegislacao legislacao : legislacoes ) + { + rows.add( new ColumnizedObjectArray( new Object[]{ legislacao, legislacao.getCategoria(), legislacao.getDescricao() }, true ) ); + } + table.setRows( rows ); + } + } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java index ddd10942..3cb1cbd1 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java @@ -1,10 +1,77 @@ 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.util.Collections; +import java.util.List; +import java.util.Vector; + import javax.swing.JPanel; +import leaf.ui.SimpleTable; +import siprp.database.cayenne.objects.HsRelatorio; +import siprp.database.cayenne.objects.HsRelatorioNormalizacao; + +import com.evolute.utils.tables.ColumnizedObjectArray; + public class RelatorioNormalizacaoPanel extends JPanel { private static final long serialVersionUID = 1L; + private HsRelatorio relatorio = null; + + private final SimpleTable table = new SimpleTable( "C" + oacute + "digo", "Normaliza" + ccedil + atilde + "o", "" ); + + public RelatorioNormalizacaoPanel() + { + startupComponents(); + setupLayout(); + placeComponents(); + } + + private void startupComponents() + { + table.getTable().fixColumnWidth(0,50); + table.getTable().fixColumnWidth(2,100); + } + + private void setupLayout() + { + TableLayout layout = new TableLayout( new double[]{ TableLayout.FILL }, new double[]{ TableLayout.FILL } ); + this.setLayout( layout ); + } + + private void placeComponents() + { + this.add( table, new TableLayoutConstraints( 0, 0 ) ); + } + + public void setRelatorio( HsRelatorio relatorio ) + { + this.relatorio = relatorio; + refresh(); + } + + private void refresh() + { + table.clear(); + if( relatorio != null ) + { + List normalizacoes = relatorio.getHsRelatorioNormalizacaoArray(); + Collections.sort( normalizacoes ); + Vector rows = new Vector(); + for( HsRelatorioNormalizacao normalizacao : normalizacoes ) + { + rows.add( new ColumnizedObjectArray( new Object[]{ normalizacao, normalizacao.getCodigo(), normalizacao.getDescricao(), normalizacao.getPortuguesa() ? "Portuguesa" : "Internacional" }, true ) ); + } + table.setRows( rows ); + } + } + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java index b12da697..6cb2d286 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java @@ -91,7 +91,7 @@ public class VerAreasRelatorioPanel extends JPanel } return(this); } - }); + } ); } private void setupLayout() diff --git a/trunk/common/src/leaf/ui/SimpleTable.java b/trunk/common/src/leaf/ui/SimpleTable.java new file mode 100644 index 00000000..756cbb51 --- /dev/null +++ b/trunk/common/src/leaf/ui/SimpleTable.java @@ -0,0 +1,84 @@ +package leaf.ui; + +import java.util.List; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionListener; + +import com.evolute.utils.tables.BaseTable; +import com.evolute.utils.tables.VectorTableModel; + +public class SimpleTable extends JScrollPane +{ + + private static final long serialVersionUID = 1L; + + private final VectorTableModel model; + + private final BaseTable table; + + public SimpleTable( String ... columnName ) + { + model = new VectorTableModel( columnName ); + table = new BaseTable( model ); + setViewportView(table); + setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + + public VectorTableModel getModel() + { + return model; + } + + public BaseTable getTable() + { + return table; + } + + public void setTitle(String title) + { + setBorder(BorderFactory.createTitledBorder(title)); + } + + public void addListSelectionListener(ListSelectionListener listener){ + table.getSelectionModel().addListSelectionListener(listener); + } + + public void setRows( Vector rows ) + { + model.setValues( rows ); + } + + public ROW_CLASS getSelectedRow() + { + ROW_CLASS result = null; + int index = table.getSelectedRow(); + if( index > -1 ) + { + result = model.getRowAt( index ); + } + return result; + } + + public List getSelectedRows() + { + List result = null; + int [] index = table.getSelectedRows(); + for( int i = 0; i < index.length; ++i ) + { + result.add( model.getRowAt( index[i] ) ); + } + return result; + } + + public void clear() + { + model.clearAll(); + } + +}