diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java index d25790bb..99497eaf 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioLegislacaoPanel.java @@ -5,16 +5,23 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.Collections; import java.util.List; import java.util.Vector; +import javax.swing.JButton; import javax.swing.JPanel; import leaf.ui.SimpleTable; +import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorioLegislacao; +import siprp.database.cayenne.objects.MarcacoesEstabelecimento; +import siprp.logic.HigieneSegurancaLogic; +import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.tables.ColumnizedObjectArray; public class RelatorioLegislacaoPanel extends JPanel @@ -22,6 +29,8 @@ public class RelatorioLegislacaoPanel extends JPanel private static final long serialVersionUID = 1L; + private final JButton revert = new JButton("Reverter"); + private HsRelatorio relatorio = null; private final SimpleTable table = new SimpleTable( "Categoria", "Legisla" + ccedil + atilde + "o" ); @@ -36,17 +45,45 @@ public class RelatorioLegislacaoPanel extends JPanel private void startupComponents() { table.getTable().fixColumnWidth(0,200); + revert.addActionListener( new ActionListener() + { + + @Override + public void actionPerformed( ActionEvent e ) + { + if( relatorio != null ) + { + MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento(); + if( marcacao != null ) + { + Estabelecimentos estabelecimento = marcacao.getToEstabelecimentos(); + if( estabelecimento != null ) + { + try + { + HigieneSegurancaLogic.reverterLegislacao( relatorio, estabelecimento ); + } catch( Exception e1 ) + { + ErrorLogger.logException( e1 ); + } + } + } + refresh(); + } + } + } ); } private void setupLayout() { - TableLayout layout = new TableLayout( new double[]{ TableLayout.FILL }, new double[]{ TableLayout.FILL } ); + TableLayout layout = new TableLayout( new double[]{ TableLayout.MINIMUM, TableLayout.FILL }, new double[]{ TableLayout.MINIMUM, TableLayout.FILL } ); this.setLayout( layout ); } private void placeComponents() { - this.add( table, new TableLayoutConstraints( 0, 0 ) ); + this.add( table, new TableLayoutConstraints( 0, 1,1,1 ) ); + this.add( revert, new TableLayoutConstraints( 0, 0 ) ); } public void setRelatorio( HsRelatorio relatorio ) diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java index 3cb1cbd1..bb21a9b8 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioNormalizacaoPanel.java @@ -7,16 +7,24 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.Collections; import java.util.List; import java.util.Vector; +import javax.swing.JButton; import javax.swing.JPanel; import leaf.ui.SimpleTable; +import siprp.data.Estabelecimento; +import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorioNormalizacao; +import siprp.database.cayenne.objects.MarcacoesEstabelecimento; +import siprp.logic.HigieneSegurancaLogic; +import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.tables.ColumnizedObjectArray; public class RelatorioNormalizacaoPanel extends JPanel @@ -26,6 +34,8 @@ public class RelatorioNormalizacaoPanel extends JPanel private HsRelatorio relatorio = null; + private final JButton revert = new JButton("Reverter"); + private final SimpleTable table = new SimpleTable( "C" + oacute + "digo", "Normaliza" + ccedil + atilde + "o", "" ); public RelatorioNormalizacaoPanel() @@ -39,17 +49,45 @@ public class RelatorioNormalizacaoPanel extends JPanel { table.getTable().fixColumnWidth(0,50); table.getTable().fixColumnWidth(2,100); + revert.addActionListener( new ActionListener() + { + + @Override + public void actionPerformed( ActionEvent e ) + { + if( relatorio != null ) + { + MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento(); + if( marcacao != null ) + { + Estabelecimentos estabelecimento = marcacao.getToEstabelecimentos(); + if( estabelecimento != null ) + { + try + { + HigieneSegurancaLogic.reverterNormalizacao( relatorio, estabelecimento ); + } catch( Exception e1 ) + { + ErrorLogger.logException( e1 ); + } + } + } + refresh(); + } + } + } ); } private void setupLayout() { - TableLayout layout = new TableLayout( new double[]{ TableLayout.FILL }, new double[]{ TableLayout.FILL } ); + TableLayout layout = new TableLayout( new double[]{ TableLayout.MINIMUM, TableLayout.FILL }, new double[]{ TableLayout.MINIMUM, TableLayout.FILL } ); this.setLayout( layout ); } private void placeComponents() { - this.add( table, new TableLayoutConstraints( 0, 0 ) ); + this.add( table, new TableLayoutConstraints( 0, 1,1,1 ) ); + this.add( revert, new TableLayoutConstraints( 0, 0 ) ); } public void setRelatorio( HsRelatorio relatorio ) diff --git a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java index 99ae152b..f11294a3 100644 --- a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java @@ -301,7 +301,7 @@ public class HigieneSegurancaLogic revertMedidasAndRiscos(posto.getHsPostoRiscoArray(),rPosto); } - private static void reverterLegislacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception + public static void reverterLegislacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception { int legislacaoSize = relatorio.getHsRelatorioLegislacaoArray().size(); for(int i = 0; i < legislacaoSize; ++i ) @@ -331,7 +331,7 @@ public class HigieneSegurancaLogic return result; } - private static void reverterNormalizacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception + public static void reverterNormalizacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception { int normalizacaoSize = relatorio.getHsRelatorioNormalizacaoArray().size(); for(int i = 0; i < normalizacaoSize; ++i )